{"id":88,"date":"2008-08-26T14:50:39","date_gmt":"2008-08-26T18:50:39","guid":{"rendered":"http:\/\/www.dev-notes.com\/blog\/2008\/08\/26\/export-oracle-synonyms-to-text-file\/"},"modified":"2008-08-26T14:50:39","modified_gmt":"2008-08-26T18:50:39","slug":"export-oracle-synonyms-to-text-file","status":"publish","type":"post","link":"https:\/\/www.dev-notes.com\/blog\/2008\/08\/26\/export-oracle-synonyms-to-text-file\/","title":{"rendered":"Export Oracle synonyms to text file"},"content":{"rendered":"<p>This is achieved by using the sys.dba_synonyms table, which means these queries must be done using an account with proper privileges.  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:oracleSynonyms.sql;\n\nselect 'create or replace '|| decode(owner,'PUBLIC','public ',null) ||  \n'synonym ' || decode(owner,'PUBLIC',null, lower(owner) || '.') ||  \nlower(synonym_name) || ' for ' || lower(table_owner) || '.' || lower(table_name) || decode(db_link,null,null,'@'||db_link) || ';'\nfrom sys.dba_synonyms \nwhere table_owner not in('SI_INFORMTN_SCHEMA','SYS','SYSTEM','ORDSYS','XDB','CTXSYS','DMSYS','EXFSYS','MDSYS','SYSMAN','WKSYS','WMSYS')\norder by owner, table_name;\n\nspool off;\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This article provides an example for Oracle DBAs to export synonyms to a flat file, which may be useful as an alternative to their regular system backups as well as a means to quickly create synonyms in a testing database that mirror another 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-88","post","type-post","status-publish","format-standard","hentry","category-oracle"],"_links":{"self":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/88","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=88"}],"version-history":[{"count":0,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/88\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/media?parent=88"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/categories?post=88"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/tags?post=88"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}