where timestamp_col =
   (select max(timestamp_col)
      from table
     where emp_no=196811)


alter procedure MY_RAISE compile;

create index CITY_ST_ZIP_NDX
on EMPLOYEE(City, State, Zip)
tablespace INDEXES;


select * from EMPLOYEE
where State='NJ';


select * from EMPLOYEE where hire_date < '1-AUG-2007';

select *
from EMPLOYEE
where Empno between 1 and 100;


select * from EMPLOYEE
where UPPER(Name) = 'JONES';


select * from EMPLOYEE
where Name = 'JONES';


create index EMP_UPPER_NAME on
EMPLOYEE(UPPER(Name));


explain plan
 for
select *
  from BOOKSHELF
 where Title like 'M%';


select * from table(DBMS_XPLAN.DISPLAY);

set autotrace on trace explain

select *
  from BOOKSHELF
 where Title like 'M%';


select Buffer_Gets,
       Disk_Reads,
       Executions,
       Buffer_Gets/Executions B_E,
       SQL_Text
 from V$SQL where executions != 0
order by Disk_Reads desc;


select SESS.Username,
       SESS_IO.Block_Gets,
       SESS_IO.Consistent_Gets,
       SESS_IO.Physical_Reads,
       round(100*(SESS_IO.Consistent_Gets
           +SESS_IO.Block_Gets-SESS_IO.Physical_Reads)/
           (decode(SESS_IO.Consistent_Gets,0,1,
               SESS_IO.Consistent_Gets+SESS_IO.Block_Gets)),2)
                 session_hit_ratio
 from V$SESS_IO sess_io, V$SESSION sess
where SESS.Sid = SESS_IO.Sid
  and SESS.Username is not null
order by Username;


select Object_Name,
       Object_Type ,
       count(*) Num_Buff
  from X$BH a, SYS.DBA_OBJECTS b
 where A.Obj = B.Object_Id
   and Owner not in ('SYS','SYSTEM')
 group by Object_Name, Object_Type;


create table state_cd_lookup
 (state_cd   char(2),
  state_nm   varchar2(50)
 )
storage (buffer_pool keep);


execute DBMS_SHARED_POOL.KEEP('APPOWNER.ADD_CLIENT','P');

execute DBMS_STATS.GATHER_SCHEMA_STATS('PRACTICE', 'COMPUTE');

create tablespace CODES_TABLES
datafile '/u01/oracle/VLDB/codes_tables.dbf'
size 500M
extent management local uniform size 256K;


select
      Owner_Name,      /*Waciciel segmentu danych*/
      Table_Name,      /*Nazwa tabeli z acuchami wierszy*/
      Cluster_Name,    /*Nazwa klastra, jeli wystpuj klastry*/
      Head_RowID       /*Rowid pierwszej czci wiersza*/
from CHAINED_ROWS;


create table ord_iot   (order_id number,    order_date date,    order_notes varchar2(1000), primary key(order_id,order_date))     organization index including order_date     overflow tablespace over_ord_tab     PARTITION BY RANGE (order_date)      (PARTITION p1 VALUES LESS THAN ('01-JAN-2005')       TABLESPACE data01,       PARTITION p2 VALUES LESS THAN (MAXVALUE)      TABLESPACE data02);

alter table EMPLOYEE_IOT
move tablespace DATA
overflow tablespace DATA_OVERFLOW;


truncate table EMPLOYEE drop storage;

truncate cluster EMP_DEPT reuse storage;

alter table EMPLOYEE
truncate partition PART3
drop storage;


create database link HR_LINK
connect to HR identified by ESNOTHR1968
using 'loc';


create materialized view LOCAL_EMP
pctfree 5
tablespace data_2
storage (initial 100K next 100K pctincrease 0)
refresh fast
    start with SysDate
    next SysDate+7
as select * from EMPLOYEE@HR_LINK;


create materialized view log on EMPLOYEE
tablespace DATA
storage (initial 500K next 100K pctincrease 0);


create procedure MY_RAISE (My_Emp_No IN NUMBER, Raise IN NUMBER)
as begin
      update EMPLOYEE@HR_LINK
      set Salary = Salary+Raise
      where Empno = My_Emp_No;
end;


execute MY_RAISE@HR_LINK(1234,2000);

create synonym MY_RAISE for MY_RAISE@HR_LINK;

execute MY_RAISE(1234,2000);

execute DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT ();

execute DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS
( interval => 30);


execute DBMS_WORKLOAD_REPOSITORY.DROP_SNAPSHOT_RANGE
    (low_snap_id => 1, high_snap_id => 10);


execute DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE
(start_snap_id => 1, end_snap_id => 10,
baseline_name => 'Punkt poniedziakowy');


execute DBMS_WORKLOAD_REPOSITORY.DROP_BASELINE
(baseline_name => 'Punkt poniedziakowy', cascade => FALSE);


