Generate Random Passwords | Database Journal

Generate Random Passwords

Dec 14, 2015
1 minute read

>>Script Language and Platform: Oracle-PL/SQL
Use this script to generate a random password.

Author: Renan Medeiros

create or replace function gera_passwd return varchar2 is passwd  varchar2(30);
passw1  varchar2(30);
passw2  varchar2(30);
passw3  varchar2(30);
passw4  varchar2(30);
zecond  number;
begin
   select dbms_random.string('Z', 3),
          trunc(dbms_random.value(091, 999)),
          dbms_random.string('Z', 2),
          trunc(dbms_random.value(07, 87))
   into   passw1,
          passw2,
          passw3,
          passw4
   from   dual;
   dbms_output.put_line('Password: '||passwd);
   zecond := to_number(to_char(sysdate,'ss'));
   if   zecond > 60
   then zecond := zecond - 60;
   end  if;
    if   zecond >= 0
   and  zecond < 16
   then passwd := passw1||passw2||passw3||passw4;
   elsif    zecond > 15
       and  zecond < 31
       then passwd := passw3||passw2||passw4||passw1;
       elsif    zecond > 30
           and  zecond < 46
           then passwd := passw3||passw1||passw4||passw2;
           else passwd := passw1||passw2||passw4||passw3;
   end  if;
   return(passwd);
end;


Disclaimer: We hope that the information on these script pages is valuable to you. Your use of the information contained in these pages, however, is at your sole risk. All information on these pages is provided “as -is”, without any warranty, whether express or implied, of its accuracy, completeness, or fitness for a particular purpose… Disclaimer Continued

Back to Database Journal Home

Database Journal Logo

DatabaseJournal.com publishes relevant, up-to-date and pragmatic articles on the use of database hardware and management tools and serves as a forum for professional knowledge about proprietary, open source and cloud-based databases--foundational technology for all IT systems. We publish insightful articles about new products, best practices and trends; readers help each other out on various database questions and problems. Database management systems (DBMS) and database security processes are also key areas of focus at DatabaseJournal.com.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.