{"id":87,"date":"2008-08-26T14:37:26","date_gmt":"2008-08-26T18:37:26","guid":{"rendered":"http:\/\/www.dev-notes.com\/blog\/2008\/08\/26\/export-oracle-users-to-text-file\/"},"modified":"2008-08-26T14:37:26","modified_gmt":"2008-08-26T18:37:26","slug":"export-oracle-users-to-text-file","status":"publish","type":"post","link":"https:\/\/www.dev-notes.com\/blog\/2008\/08\/26\/export-oracle-users-to-text-file\/","title":{"rendered":"Export Oracle users to text file"},"content":{"rendered":"<p>This is achieved by using the sys.dba_users table, which means these queries must be done using an account with proper privileges.  Beyond creation of users, the second SQL statement in the example below also generates account-locking commands for those users that are currently marked as locked.  Finally, note the output file has the extension .sql, which suggests that it can be run directly from SQL*Plus as part of an automated script, if necessary.<\/p>\n<pre class=\"code\">\nset linesize 256;\nspool c:oracleUsers.sql;\n\nselect 'create user '||username||' identified by values '||''''||password||''''||' \ndefault tablespace '||default_tablespace||' \ntemporary tablespace '||temporary_tablespace||' \nquota unlimited on '||default_tablespace||' \nquota unlimited on '||temporary_tablespace||';' as \"-- create_users\"\nfrom sys.dba_users \nwhere default_tablespace not in('SYSAUX','SYSTEM')\norder by username;\n\nselect concat(concat('alter user ',du.username),' account lock;') as \"--lock_users\"\nfrom sys.dba_users du\nwhere du.account_status<>'OPEN'\nand du.default_tablespace not in('SYSAUX','SYSTEM')\norder by du.username;\n\nspool off;\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This article provides an example for Oracle DBAs to export users to a flat file, which may be useful as an alternative to their regular system backups as well as a means to quickly create some users in a testing database.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-87","post","type-post","status-publish","format-standard","hentry","category-oracle"],"_links":{"self":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/87","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/comments?post=87"}],"version-history":[{"count":0,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/87\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/media?parent=87"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/categories?post=87"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/tags?post=87"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}