Advertisement
tsnaik

DBS Lab2

Jul 14th, 2015
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. rlwrap with sqlplus in linux
  2.  
  3. -> select count(*) from math_sample; // for count including null value too
  4.  
  5. -> idata=null N.P , Use idata is null // use is keyword for comparing null
  6.  
  7. -> select max(colname) from table // max value in col , same for min,avg
  8.  
  9. -> select avg(all colname) from table // includees duplicates
  10.  
  11. -> select avg(distinct colname ) from table // dublicates are not counted
  12.  
  13. -> create table math_sample2 as( select rownum as srno , idata from math_sample m1);
  14. rename math_sample2 to math_sample ;
  15.  
  16. -> select dbms_random.Value(1,1000) from dual; // generate random no
  17.  
  18. -> alter table table_name add (colname number(5));
  19.  
  20. -> update table_name set colname=value,col2=value2 where condition // to update the value
  21.  
  22. -> for loop and pl/sql // reffer moodle doc
  23.  
  24. -> printf=> dbms_output.put_line('String' || d)// '||' for concatination
  25.  
  26. -> Question 1.
  27.  
  28. 1. update product_master set sell_price=1150 where description like '1.44floppies';
  29. 2. delete from client_master where client_no=0001;
  30. 3. update client_master set city='Bombay' where client_no=0005;
  31. 4. update client_master set bal_due=1000 where client_no=0002;
  32. 5. update product_master set sell_price=1.5*sell_price where sell_price>1500;
  33. 6. select name from client_master where name like'_a*';
  34. 7.
  35. 8. select * from product_master order by sell_price asc , qty_on_hand asc;
  36. 9. select count(*) from client_master;
  37. 10. select avg(all sell_price) from product_master;
  38. 11. select min(sell_price) from product_master;
  39. 12. select min(sell_price) min_price , max(sell_price) max_price from product_master;
  40. 13. select count(*) from product_master where sell_price>=1500 ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement