|
- select * from dba_tablespaces;
- select * from dba_extents e where e.owner='HR' and e.segment_name='T04209_UNAME';
- select * from dba_segments s where s.owner='HR' and s.segment_name='T04209_UNAME';
- create tablespace tbs10g datafile size 10M
- segment space management auto;
- create tablespace tbs11g datafile size 10M uniform size 512K;
- select t.pct_free, t.pct_used, t.ini_trans
- from dba_tables t where t.owner='HR' and t.table_name='EMPLOYEES';
-
-
- alter table hr.employees initrans 10;
-
- alter table hr.employees pctfree 20;
复制代码
查表空间用量:
- select tablespace_name, sum(bytes)/1024/1024 from dba_data_files
- group by tablespace_name;
-
-
-
- select tablespace_name, sum(bytes)/1024/1024 from dba_free_space
- group by tablespace_name;
-
- select sum(bytes)/1024/1024 from dba_undo_extents
- where status <> 'EXPIRED';
-
-
- select sum(tfs.free_space)/1024/1024 from dba_temp_free_space tfs;
复制代码- select * from dba_users u
- where u.username='HR';
-
- alter user hr account lock;
-
- alter user hr account unlock;
-
- alter user hr password expire;
-
- select * from system_privilege_map;
-
- select * from table_privilege_map;
复制代码- select * from dba_sys_privs;
- select * from dba_tab_privs;
- select * from dba_col_privs;
- select * from dba_role_privs;
- select * from role_sys_privs;
- select * from role_tab_privs;
- select * from role_role_privs;
复制代码
- User altered.
- SQL> alter role role1 identified by oracle_4U;
- Role altered.
- SQL> alter user hr default role none;
- User altered.
- SQL>
复制代码- ALTER PROFILE "PROFILE1" LIMIT PASSWORD_LOCK_TIME .000694444
- FAILED_LOGIN_ATTEMPTS 1
复制代码- ALTER PROFILE "PROFILE1" LIMIT PASSWORD_LIFE_TIME .000694444
- PASSWORD_GRACE_TIME .000694444
复制代码- ALTER PROFILE "PROFILE1" LIMIT PASSWORD_REUSE_MAX 1
- PASSWORD_REUSE_TIME .0069444
复制代码
上完了1Z0-052:0、1、2、3、4、5、6、7、8、9、10、11、12、13、14、15、16、17、18;上完了1Z0-053:0、1、2、3、4、5、6、7、8、9、10、11、12、13、14、15、16、17、18、19、20
- select * from dba_obj_audit_opts;
- select * from dba_priv_audit_opts;
- select s.audit_option from dba_stmt_audit_opts s
- minus
- select p.privilege from dba_priv_audit_opts p;
- select count(*) from dba_audit_trail;
- select count(*) from aud$;
- select bytes, tablespace_name from dba_segments where segment_name='AUD
- [/color]
- ;
- create tablespace tbsaudit datafile size 50M ;
- alter table aud$ move tablespace tbsaudit;
- select * from dba_audit_trail
- where action_name not in ('LOGOFF','LOGON') ;
-
- noaudit create session ;
- audit create session by hr whenever successful;
- audit create session by sh whenever not successful;
- audit select on hr.employees by session whenever successful ;
- audit select any table by oe by session whenever successful ;
复制代码- select * from dba_audit_trail
- where username='OE'
- order by 5 desc ;
复制代码- SQL> alter system set audit_trail=db,extended scope=spfile;
- System altered.
复制代码
-----------------------------
- select * from dba_audit_trail
- where username='OE'
- order by 5 desc ;
-
-
- select * from dba_obj_audit_opts;
- select * from dba_priv_audit_opts;
- select s.user_name, s.audit_option from dba_stmt_audit_opts s
- minus
- select p.user_name , p.privilege from dba_priv_audit_opts p;
- select * from dba_stmt_audit_opts s;
- select * from v$xml_audit_trail order by 6 desc ;
-
- select * from dba_common_audit_trail order by 6 desc;
- audit table by hr ;
复制代码 --------------------------------------
- select * from dba_audit_policies;
- begin
- dbms_fga.add_policy(object_schema => 'HR',
- object_name => 'EMPLOYEES',
- policy_name => 'MYPOLICY1',
- audit_condition => 'department_id=20',
- audit_column => 'salary,commission_pct',
- handler_schema => 'SYS',
- handler_module => 'PROC_FGA',
- statement_types => 'SELECT,UPDATE',
- audit_trail => dbms_fga.XML+dbms_fga.EXTENDED,
- audit_column_opts => dbms_fga.ANY_COLUMNS);
- end;
- select * from v$xml_audit_trail order by 6 desc ;
复制代码 | AUDIT_TYPE | SESSION_ID | PROXY_SESSIONID | STATEMENTID | ENTRYID | EXTENDED_TIMESTAMP | GLOBAL_UID | DB_USER | CLIENTIDENTIFIER | EXT_NAME | OS_USER | OS_HOST | OS_PROCESS | TERMINAL | INSTANCE_NUMBER | OBJECT_SCHEMA | OBJECT_NAME | POLICY_NAME | NEW_OWNER | NEW_NAME | ACTION | STATEMENT_TYPE | TRANSACTIONID | RETURNCODE | SCN | COMMENT_TEXT | AUTH_PRIVILEGES | GRANTEE | PRIV_USED | SES_ACTIONS | OS_PRIVILEGE | ECONTEXT_ID | SQL_BIND | SQL_TEXT | OBJ_EDITION_NAME | DBID | 1 | 2 | 1180527 | 0 | 10 | 3 | 27-8月 -19 09.10.30.978840 上午 +08:00 | | HR | | oracle | oracle | station76.example.com | 17347 | | 0 | HR | EMPLOYEES | MYPOLICY1 | | | 0 | 1 | | 0 | 6444734 | | | | 0 | | | | | select salary from employees where department_id=20 | | 1541741703 | 2 | 1 | 1180527 | 0 | 10 | 2 | 27-8月 -19 09.10.30.977847 上午 +08:00 | | HR | | | oracle | station76.example.com | 17347 | pts/2 | 0 | HR | EMPLOYEES | | | | 103 | 0 | | 0 | 6444734 | | | | 0 | ---------S------ | | | | select salary from employees where department_id=20 | | 1541741703 | 3 | 1 | 1180527 | 0 | 1 | 1 | 27-8月 -19 09.10.14.459562 上午 +08:00 | | HR | | | oracle | station76.example.com | 17347 | pts/2 | 0 | | | | | | 100 | 0 | 0000000000000000 | 0 | 0 | Authenticated by: DATABASE | | | 5 | | | | | | | 1541741703 | 4 | 8 | 0 | 0 | 0 | 1 | 27-8月 -19 09.09.46.370170 上午 +08:00 | | SYS | | | Apple | WORKGROUP\DESKTOP-69JBF6I | 17304 | DESKTOP-69JBF6I | 0 | | | | | | 0 | 0 | | 0 | 0 | | | | 0 | | SYSDBA | | | CONNECT | | 1541741703 | 5 | 8 | 0 | 0 | 0 | 1 | 27-8月 -19 09.09.20.904543 上午 +08:00 | | SYS | | | Apple | WORKGROUP\DESKTOP-69JBF6I | 17283 | DESKTOP-69JBF6I | 0 | | | | | | 0 | 0 | | 0 | 0 | | | | 0 | | SYSDBA | | | CONNECT | | 1541741703 | 6 | 8 | 0 | 0 | 0 | 1 | 27-8月 -19 09.09.20.592377 上午 +08:00 | | SYS | | | Apple | WORKGROUP\DESKTOP-69JBF6I | 17281 | DESKTOP-69JBF6I | 0 | | | | | | 0 | 0 | | 0 | 0 | | | | 0 | | SYSDBA | | | CONNECT | | 1541741703 | 7 | 8 | 0 | 0 | 0 | 1 | 27-8月 -19 09.09.11.620919 上午 +08:00 | | SYS | | | Apple | WORKGROUP\DESKTOP-69JBF6I | 17272 | DESKTOP-69JBF6I | 0 | | | | | | 0 | 0 | | 1017 | 0 | | | | 0 | | NONE | | | CONNECT | | 1541741703 | 8 | 8 | 0 | 0 | 0 | 1 | 27-8月 -19 09.08.28.825830 上午 +08:00 | | / | | | oracle | station76.example.com | 17194 | pts/2 | 0 | | | | | | 0 | 0 | | 0 | 0 | | | | 0 | | SYSDBA | | | CONNECT | | 1541741703 | 9 | 8 | 0 | 0 | 0 | 1 | 27-8月 -19 09.08.21.676245 上午 +08:00 | | / | | | oracle | station76.example.com | 17170 | pts/2 | 0 | | | | | | 0 | 0 | | 0 | 0 | | | | 0 | | SYSDBA | | | CONNECT | | 0 |
SQL> conn hr/oracle_4U
Connected.
SQL> select salary from employees where department_id=20 ;
select salary from employees where department_id=20
*
ERROR at line 1:
ORA-28144: Failed to execute fine-grained audit handler
ORA-06550: line 1, column 7:
PLS-00201: identifier 'SYS.PROC_FGA' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
------------------------------------------------------------
- select * from dba_obj_audit_opts;
-
- noaudit select on hr.employees;
- select * from dba_audit_policies;
- begin
- dbms_fga.add_policy(object_schema => 'HR',
- object_name => 'EMPLOYEES',
- policy_name => 'MYPOLICY1',
- audit_condition => 'department_id=20',
- audit_column => 'salary,commission_pct',
- handler_schema => 'SYS',
- handler_module => 'PROC_FGA',
- statement_types => 'SELECT,UPDATE',
- audit_trail => dbms_fga.XML+dbms_fga.EXTENDED,
- audit_column_opts => dbms_fga.ANY_COLUMNS);
- end;
- select * from v$xml_audit_trail order by 6 desc ;
- declare
- v_filehandle UTL_FILE.FILE_TYPE;
- begin
- v_filehandle:=utl_file.fopen(location => 'FGALOG',filename => 'FGA.log',open_mode => 'w');
-
- utl_file.put_line(file => v_filehandle,buffer => 'XXXXX');
- utl_file.new_line( v_filehandle);
- utl_file.fclose( v_filehandle);
- end;
- CREATE OR REPLACE PROCEDURE PROC_FGA ( object_schema VARCHAR2, object_name VARCHAR2, policy_name
- VARCHAR2 ) AS
- v_filehandle UTL_FILE.FILE_TYPE;
- begin
- v_filehandle:=utl_file.fopen(location => 'FGALOG',filename => 'FGA.log',open_mode => 'w');
-
- utl_file.put_line(file => v_filehandle,buffer =>object_schema );
- utl_file.put_line(file => v_filehandle,buffer =>object_name);
- utl_file.put_line(file => v_filehandle,buffer =>policy_name);
- utl_file.put_line(file => v_filehandle,buffer =>sys_context('userenv','ip_address'));
- utl_file.put_line(file => v_filehandle,buffer => sys_context('userenv','session_user'));
- utl_file.put_line(file => v_filehandle,buffer =>sys_context('userenv','current_user'));
-
- utl_file.put_line(file => v_filehandle,buffer =>to_char(sysdate,'YYYY-MM-DD:HH24:MI:SS'));
-
- utl_file.put_line(file => v_filehandle,buffer =>sys_context('userenv','authentication_type'));
- utl_file.new_line( v_filehandle);
-
-
-
- utl_file.fclose( v_filehandle);
- end;
复制代码
HR
EMPLOYEES
MYPOLICY1
192.168.0.76
HR
SYS
2019-08-27:10:02:18
DATABASE
--------------------------------------------------------
- CREATE OR REPLACE TRIGGER hrsalary_audit
- AFTER UPDATE OF salary
- ON hr.employees
- REFERENCING NEW AS NEW OLD AS OLD
- FOR EACH ROW
- declare
- v_filehandle UTL_FILE.FILE_TYPE;
- BEGIN
- IF :old.salary != :new.salary THEN
- v_filehandle:=utl_file.fopen(location => 'FGALOG',filename => 'VALUE.log',open_mode => 'w');
- utl_file.put_line(file => v_filehandle,buffer =>sys_context('userenv','ip_address'));
- utl_file.put_line(file => v_filehandle,buffer => sys_context('userenv','session_user'));
- utl_file.put_line(file => v_filehandle,buffer =>sys_context('userenv','current_user'));
- utl_file.put_line(file => v_filehandle,buffer =>to_char(sysdate,'YYYY-MM-DD:HH24:MI:SS'));
- utl_file.put_line(file => v_filehandle,buffer =>sys_context('userenv','authentication_type'));
- utl_file.put_line(file => v_filehandle,buffer =>'OLD is: '||:old.salary);
- utl_file.put_line(file => v_filehandle,buffer =>'NEW is: '||:new.salary);
- utl_file.new_line( v_filehandle);
- utl_file.fclose( v_filehandle);
- END IF;
- END;
- select * from dba_errors;
- select * from dba_source s where s.owner='SYS' and s.name='HRSALARY_AUDIT';
复制代码
HR
SYS
2019-08-27:10:26:45
DATABASE
OLD is: 26000
NEW is: 27000
|
|