Skip to content

Commit

Permalink
[rdbms][oracle] add tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
GradedJestRisk committed Jan 8, 2025
1 parent c58565b commit 42bb924
Show file tree
Hide file tree
Showing 328 changed files with 297,976 additions and 80 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
---------------------------------------------------------------------------
-------------- System privileges (NOT ON OBJECTS) -------------
---------------------------------------------------------------------------
# Privileges

-- System privileges
-- Granted to X
## System privileges (NOT ON OBJECTS)

System privileges
Granted to X
```oracle
SELECT
sys_prv.*
FROM
dba_sys_privs sys_prv
WHERE 1=1
AND sys_prv.grantee = 'DBOFAP'
;
```

System privileges
Granted to X
```oracle
SELECT
sys_prv.*
FROM
dba_sys_privs sys_prv
WHERE 1=1
-- AND sys_prv.grantee = 'DBOFAP'
AND sys_prv.privilege LIKE '%VIEW%'
;
```


-- System privileges
-- For a specific privilege
System privileges
For a specific privilege
```oracle
SELECT
sys_prv.*
FROM
Expand All @@ -24,17 +41,22 @@ WHERE 1=1
ORDER BY
sys_prv.grantee
;
```

-- current user
Current user
```oracle
select * from user_sys_privs
;
---------------------------------------------------------------------------
-------------- Direct privileges (on objects) -------------
---------------------------------------------------------------------------
```

## Direct privileges (on objects)

-- Directly granted privileges
-- Example of SYS to a SYS role

```oracle
SELECT
prv_drc.grantor,
prv_drc.privilege,
Expand All @@ -45,8 +67,10 @@ FROM
WHERE 1=1
-- AND prv_drc.grantor = 'SYS'
-- AND prv_drc.grantee = 'SELECT_CATALOG_ROLE'
AND prv_drc.table_name = UPPER ('REF_K_BATCHS')
-- AND prv_drc.table_name = UPPER ('REF_K_BATCHS')
AND UPPER(prv_drc.table_name) LIKE 'V_$SESS_TIME_MODEL%'
;
```

-- Directly granted privileges
-- Example of SYS to a user
Expand Down Expand Up @@ -80,35 +104,33 @@ WHERE 1=1
;


---------------------------------------------------------------------------
-------------- Role granted privileges -------------
---------------------------------------------------------------------------
## Role granted privileges

-- Indirectly granted privileges (by role)

```oracle
SELECT
prv_rl.granted_role,
prv_rl.grantee
FROM
dba_role_privs prv_rl
WHERE 1=1
-- AND prv_rl.granted_role = 'DBOFAP'
AND prv_rl.grantee = 'EXPRDO'
AND prv_rl.grantee = 'USERNAME'
-- AND prv_rl.table_name = UPPER ('filiere')
;
```



-----------------------------------------------------------------------------
---------- Privil�ges -----------------
-----------------------------------------------------------------------------

## Privileges
-- Privil�ges syst�mes (CREATE USER, DROP USER,..)
SELECT * FROM
user_sys_privs
;

-- Privil�ges objets tables
-- Pour utilisateur
Privil�ges objets tables
Pour utilisateur
```oracle
SELECT
prv_tls.grantor,
prv_tls.grantee,
Expand All @@ -117,11 +139,13 @@ SELECT
prv_tls.*
FROM all_tab_privs prv_tls
WHERE 1=1
AND prv_tls.grantee = 'SYSTEM'
AND prv_tls.table_name = 'TBL_TEST' --UPPER('wrk_gen_trc_fil')
--AND prv_tls.grantee = 'SYSTEM'
-- AND prv_tls.table_name = 'TBL_TEST' --UPPER('wrk_gen_trc_fil')
-- AND prv_tls.table_name LIKE 'V$%'
;
```


-- Privil�ges objets tables
-- Pour table
Expand All @@ -148,9 +172,8 @@ WHERE 1=1
-- AND tls_rl.grantee = 'THCC'
;

-------------------------------
---------- R�le -------
-------------------------------
# Role

SELECT *
FROM
role_role_privs rl
Expand All @@ -165,9 +188,7 @@ WHERE 1=1
AND rl.role = 'EXP_RDO_ROLE'
;

-------------------------------
---------- R�le + Droits -------
-------------------------------
## Roles + rights

-- R�le: droits sur tables
SELECT *
Expand All @@ -193,10 +214,7 @@ WHERE 1=1
AND rl_tbl.table_name = UPPER('wrk_gen_trc_fil')
;

-------------------------------
---------- R�le + Utilisateur -------
-------------------------------

## Role + user
-- R�le: droits sur tables
SELECT
rl_tls.username rl_tls
Expand All @@ -220,11 +238,7 @@ ORDER BY




---------------------------------------------------------------------------
-------------- Role -------------
---------------------------------------------------------------------------

## Role

-- Priorit�
-- Tous
Expand Down Expand Up @@ -262,33 +276,27 @@ WHERE 1=1



## Add privileges


-------------------------------
---------- Ajout privil�ges -------
-------------------------------
Table
```oracle
GRANT
SELECT, INSERT, UPDATE, DELETE
ON
db_mt_kp
TO
ptop
;

CREATE SYNONYM
ptop.db_mt_kp
FOR pegase.db_mt_kp
;

select * from db_mt_kp
;

DROP synonym is_capital_protege
;

CREATE SYNONYM
ptop.is_capital_protege_seq
FOR pegase.is_capital_protege_seq
;


```

All system views
```oracle
GRANT select any dictionary TO USERNAME;
GRANT execute ON sys.dbms_session TO USERNAME;
```

System view
```oracle
GRANT SELECT ON V$SESS_TIME_MODEL TO USERNAME;
GRANT SELECT ON sys.v_$sess_time_model TO USERNAME;
```
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions RDBMS/ORACLE/SQL/session/generate-activity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generate activity

30 s
```oracle
with /* slow */ rws as (
select rownum x from dual connect by level <= 1000
)
select count(*) from rws, rws, rws;
```
8 changes: 8 additions & 0 deletions RDBMS/ORACLE/SQL/session/session.sql
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,11 @@ WHERE 1=1
AND v.sql_id = sss.sql_id
;


-- Query type: CREATE, INSERT
SELECT * FROM v$sqlcommand;

SELECT qry.*
FROM v$session ssn INNER JOIN v$sqlcommand qry ON qry.command_type = ssn.command
WHERE ssn.username = 'USERNAME';

1 change: 1 addition & 0 deletions RDBMS/ORACLE/SQL/tuning/Overview/TOP/TOP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://antognini.ch/top/table-of-contents/
Loading

0 comments on commit 42bb924

Please sign in to comment.