{"id":1166,"date":"2020-06-08T22:48:39","date_gmt":"2020-06-09T01:48:39","guid":{"rendered":"http:\/\/soudba.com.br\/?p=1166"},"modified":"2020-06-08T22:48:39","modified_gmt":"2020-06-09T01:48:39","slug":"use-sqlplus-to-help-you","status":"publish","type":"post","link":"https:\/\/www.soudba.com.br\/?p=1166","title":{"rendered":"Use sqlplus to help you!"},"content":{"rendered":"\n<p>Each time we use sqlplus &#8211; we usually need check dataguard status, database role, and collect details on our system. This help us to be more proactive and collect data to leave the database in same status we started to work. A good approach is to get all details automatically without getting trash for our screen output. Same examples are below &#8211; I have been using this a couple of years and is very helpful in my day by day.<\/p>\n\n\n<p><strong>glogin.sql &#8211; update the file under $ORACLE_HOME\/sqlplus\/admin<\/strong><\/p>\n\n\n<pre class=\"wp-block-code\"><code>set linesize 200\ndefine _editor=vi\nset serveroutput on size 1000000\nset pagesize 9999\ncolumn plan_plus_exp format a80\ncolumn global_name new_value gname\nset termout off\ndefine gname=idle\ncolumn global_name new_value gname\nselect lower(user)||'@'||instance_name||'('||host_name||')' global_name from v$instance;\n--set sqlprompt '&amp;gname&gt; '\nset termout on\ncolumn db_unique_name format a16\ncolumn database_role format a16\ncolumn db_version format a10\ncolumn db_status format a8\ncolumn db_compatible format a10\ncolumn db_version heading VERSION\ncolumn db_status heading STATUS\ncolumn db_compatible heading COMPATIBLE\nselect d.db_unique_name, d.database_role, d.open_mode, v.version db_version,\np.value db_compatible, v.status db_status\nfrom gv$database d, gv$instance v, gv$parameter p\nwhere p.name = 'compatible'\nand d.inst_id=v.inst_id and v.inst_id = p.inst_id\n;\ncol logins format a8\ncolumn instance_name format A14\ncolumn status format A8\ncolumn CONNECTED format A12\ncolumn host_name format A34\nselect host_name,instance_name,\nstatus, to_char(startup_time,\n'DD-MON-YYYY HH24:MI ') \"Startup time\",logins,\ndecode(instance_name,(select instance_name from v$instance) ,'CURRENT','NOT CURRENT') CONNECTED\nfrom gv$instance\n\/<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Each time we use sqlplus &#8211; we usually need check dataguard status, database role, and collect details on our system. This help us to be more proactive and collect data to leave the database in same status we started to &hellip; <a href=\"https:\/\/www.soudba.com.br\/?p=1166\">Continue lendo <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1166","post","type-post","status-publish","format-standard","hentry","category-sem-categoria"],"_links":{"self":[{"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=\/wp\/v2\/posts\/1166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1166"}],"version-history":[{"count":0,"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=\/wp\/v2\/posts\/1166\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}