Retain User Password

   set long 30000

with t as
 ( select (dbms_metadata.get_ddl('USER','RD_PDBA')) ddl from dual )
  select replace(substr(ddl,1,instr(ddl,'DEFAULT')-1),'CREATE','ALTER')||';'
  from t;
   

Retain User Password - alternative

Run the following:

select 'alter user ' || su.name || ' identified by values' || ' ''' || spare4 || ';' || su.password || ''';' from sys.user$ su join dba_users du on su.name = du.username;

alternatively: 

with t as
 ( select TO_CHAR(dbms_metadata.get_ddl('USER','LAPS')) ddl from dual )
  select replace(substr(ddl,1,instr(ddl,'DEFAULT')-1),'CREATE','ALTER')||';'
  from t;

alter profile APPUSER_PROFILE  LIMIT PASSWORD_REUSE_MAX unlimited;
alter profile APPUSER_PROFILE  LIMIT  PASSWORD_REUSE_TIME unlimited;
alter profile APPUSER_PROFILE LIMIT PASSWORD_VERIFY_FUNCTION null;

Then make sure that you have the alter statement all in one line.I normally just put in a text doc and copy and paste

alter user SMER identified by values 'S:888E3BB749979213160CABBB0C0CB117B89B27E2
E61765B14BA3813D23EC;T:F43A05AAD54A3B57FA0AC2828809B0C8152A06E26ADEDB8FFFAF6F326
59A7FDDC724E74E48DF758F332DD9C86D4F10502CF1141543C77AE1BBD7A791350F3DBAC73964745
EA8AFF17B1CE40BBAD3A492;931F7FC191A7C903';

alter profile APPUSER_PROFILE LIMIT PASSWORD_VERIFY_FUNCTION VERIFY_FUNCTION_APPUSER;
alter profile APPUSER_PROFILE  LIMIT PASSWORD_REUSE_MAX 12;
alter profile APPUSER_PROFILE  LIMIT  PASSWORD_REUSE_TIME 365;

DB Link

set long 99999 lines 100
col ddl format a100
select dbms_metadata.get_ddl('DB_LINK', 'RD_DBRI.WORLD', 'PUBLIC') as ddl from dual;

Procedures

set pages 0
set lines 150

spool DMON_RECO_STATUS_PRC.sql

select text
from dba_source
where name = 'DMON_RECO_STATUS_PRC'
and owner = 'DMON'
and type = 'PROCEDURE'
/
spool off

Procedure

Generate DDL scripts using "DBMS_METADATA" package

To Generate all Tablespace DDL's:

set long 2000;
select dbms_metadata.get_ddl('TABLESPACE',tb.name) from v$tablespace tb ;

for 1 tablespace:
select dbms_metadata.get_ddl('TABLESPACE','TABLESPACE_NAME') from dual;


To Generate DDL for a USER :

set long 5000 linesize 280;
select dbms_metadata.get_ddl('USER', 'USER_NAME')  from dual;


To Generate DDL for all PROFILE's :

set long 5000;
select dbms_metadata.get_ddl('PROFILE',a.profile) from dba_profiles a;

For 1 profile:
 select dbms_metadata.get_ddl('PROFILE','PROFILE_NAME') from dual;


To Generate DDL for any TABLE :

set long 5000;
select dbms_metadata.get_ddl('TABLE','TABLE_NAME','OWNER') from dual;


To Generate DDL for any INDEX :

select dbms_metadata.get_ddl('INDEX',’INDEX_NAME’,'OWNER') from dual;


To Generate all INDEX DDL’s on a TABLE:

select dbms_metadata.get_dependent_ddl('INDEX',’TABLE_NAME','OWNER') from dual;

The above command will generate all index ddl’s which are on table.

To Generate DDL for a Specific SEQUENCE :

set long 5000;
set linesize 200;
select dbms_metadata.get_ddl('SEQUENCE','SEQUENCE_NAME','OWNER_NAME') from dual;


To Generate DDL for a Specific TRIGGER:

set long 5000;
set linesize 200;
SQL> select dbms_metadata.get_ddl('TRIGGER','TRGGER_NAME','TRIGGER_OWNER') from dual;



Profile DDL

-- -----------------------------------------------------------------------------------
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;
/

select dbms_metadata.get_ddl('PROFILE', profile) as profile_ddl
from   (select distinct profile
        from   dba_profiles)
where  profile like upper('%&1%');

set linesize 80 pagesize 14 feedback on verify on