Vous êtes sur la page 1sur 2

lession 8

---------------------------------select * from emp_demo;


desc user_objects;
select * from user_objects where object_name='EMP_DEMO';
alter table emp_demo add mid number(5);
alter table emp_demo drop column mid;
insert into emp_demo values(105,'ss',25000,'09-MAR-14',12);
insert into emp_demo values(106,'abc',25000,'09-MAR-14',13);
savepoint a (create the )
update table emp_demo set edid=40 where eid = 105;
rollback to savepoint a (revert the savepoint a)
alter table emp_demo drop (ehiredate,edid); (drop multipal column)
alter table emp_demo drop column esal;
alter table emp_demo rename column eid to emp_id;()
alter table emp_demo modify ename varchar2(40); (its allow upto 4000 charater wi
th space and spacial characters)
drop table emp_demo;
select * from recyclebin; (to chk drop table )
flashback table emp_demo to before drop; (to retrive the drop object from the re
cyclebin)
drop table emp_demo purge; (delete object permanantly)
purge recyclebin; (flash the recyclebin)
rename emp_demo to edemo; (to rename the table only possible)
alter table edemo rename to emp_demo; (to rename the table only possible)
truncate table emp_demo;

==================================================================
select last_name from employees;
select last_name, lower(last_name) from employees; (to print the record in to lo
wer case)
select last_name, upper(last_name) from employees; (to print the record in to up
per case)
select last_name, upper(last_name),upper('virag') from employees; (to print the
record in to upper case)
select upper('virag') from dual; (by default a blank table its owner is sys)
select initcap('virag shah') from dual; (to print the data in the capitalize sen
tance)
select concat('virag', 'shah') from dual; (to concetinate the to parameter)
select substr ('dbaconsultant',1,3) from dual; (to print the some object)
select substr ('dbaconsultant',4) from dual; (from the starting point to all cha
racter)
select substr ('dbaconsultant goregaon',-4) from dual; (with negetive mark)
select length (last_name), last_name from employees; (length of the column data)
select instr('dbaconstanct','a',1,1) from dual;
select instr('dbaconstanct','a',-1,1) from dual; (with negetive)
select salary, lpad(salary,10,'*') from employees; (left padding)
select salary, rpad(salary,10,'*') from employees; (right padding)
select trim(leading 'd' from 'dd dbaconsultantdd') from dual; (trim from the lef
t side)
select trim(trailing 'd' from 'dd dbaconsultantdd') from dual; (trim from the ri
ght side)
select trim(both 'd' from 'dd dbaconsultantdd') from dual; (trim from both side
by default it is both)
select replace ('vs shah','vs','virag') from dual; (replace the with object)
select replace ('vsshvsah','vs') from dual; (replace without the replacer)
select round (776.228,2) from dual;

select round (722.228,-2) from dual;


select trunc (716.2244446,2) from dual; (after , what is your number it delete o
r print the remaintg number)
select trunc (716.2244446,-2) from dual; (if u r value in minus then its make th
e 0 print and ahead values)
select mod(31,3), 31/3 from dual; (chk)
select sysdate from dual; (server date)
alter session set nls_date_format='DD-MON-RR HH:MI:SS' ;
select sysdate, sysdate+7, sysdate-7 from dual;
select sysdate, hire_date, sysdate-hire_date from employees; (addition & divide
& )
select sysdate, hire_date, months_between(sysdate,hire_date) from employees;
select hire_date, add_months(hire_date,6) from employees;(add month)
select sysdate, add_months(sysdate,6) from dual; (add month)
select hire_date,next_day(hire_date,'monday') from employees; (next day of the w
eek we can use as mon,monday,2 )
select last_day(sysdate) from dual; (last date of the given date of month)
select to_char(sysdate,'ddspth month year') from dual; (print the date in charac
ter mode from the date number with diffrent parameter in page no 162)
select to_char(salary,'L99,999.00'), salary from employees; (print character of
the given value)
select to_char(salary,'L09,999.00'), salary from employees; (to add the padding
OR proper alignment of the output)
select * from employees where hire_date =to_date('99-jun-21','RR-MON-DD'); (conv
ert the date in specify date how you want the date to be print)
===================================
lession 4
select department_id, sum(salary) from employees group by department_id; (group
of department & sum of salary)
select department_id, job_id,sum(salary) from employees group by department_id,
job_id order by department_id;

Vous aimerez peut-être aussi