2 Star 0 Fork 0

mirrors_ReneNyffenegger/fatdba-Oracle-Database-Scripts

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ddl_schema.sql 1.92 KB
一键复制 编辑 原始数据 按行查看 历史
Prashant Dixit 提交于 2022-10-31 12:12 . Update ddl_schema.sql
--
-- Author: Prashant 'The FatDBA' Dixit
--
Vi Schema.sql (create sqlfile and execute)
set long 20000 longchunksize 20000 pagesize 0 linesize 1000 feedback off verify off trimspool on
column ddl format a1000
begin
dbms_metadata.set_transform_param (dbms_metadata.session_transform, SQLTERMINATOR, true);
dbms_metadata.set_transform_param (dbms_metadata.session_transform, PRETTY, true);
end;
/
variable v_username VARCHAR2(30);
exec:v_username := upper(&1);
select dbms_metadata.get_ddl(USER, u.username) AS ddl
from dba_users u
where u.username = :v_username
union all
select dbms_metadata.get_granted_ddl(TABLESPACE_QUOTA, tq.username) AS ddl
from dba_ts_quotas tq
where tq.username = :v_username
and rownum = 1
union all
select dbms_metadata.get_granted_ddl(ROLE_GRANT, rp.grantee) AS ddl
from dba_role_privs rp
where rp.grantee = :v_username
and rownum = 1
union all
select dbms_metadata.get_granted_ddl(SYSTEM_GRANT, sp.grantee) AS ddl
from dba_sys_privs sp
where sp.grantee = :v_username
and rownum = 1
union all
select dbms_metadata.get_granted_ddl(OBJECT_GRANT, tp.grantee) AS ddl
from dba_tab_privs tp
where tp.grantee = :v_username
and rownum = 1
union all
select dbms_metadata.get_granted_ddl(DEFAULT_ROLE, rp.grantee) AS ddl
from dba_role_privs rp
where rp.grantee = :v_username
and rp.default_role = YES
and rownum = 1
union all
select to_clob(/* Start profile creation script in case they are missing’) AS ddl
from dba_users u
where u.username = :v_username
and u.profile <> ‘DEFAULT’
and rownum = 1
union all
select dbms_metadata.get_ddl(‘PROFILE’, u.profile) AS ddl
from dba_users u
where u.username = :v_username
and u.profile <> ‘DEFAULT’
union all
select to_clob(‘End profile creation script */) AS ddl
from dba_users u
where u.username = :v_username
and u.profile <> DEFAULT
and rownum = 1
/
set linesize 80 pagesize 14 feedback on trimspool on verify on
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_ReneNyffenegger/fatdba-Oracle-Database-Scripts.git
git@gitee.com:mirrors_ReneNyffenegger/fatdba-Oracle-Database-Scripts.git
mirrors_ReneNyffenegger
fatdba-Oracle-Database-Scripts
fatdba-Oracle-Database-Scripts
main

搜索帮助

0d507c66 1850385 C8b1a773 1850385