snipt

Ctrl+h for KB shortcuts

Text only

Oracle - Shell

1
2
3
#I came up with a situation where i need to append @ and PATH at th starting of the all files that are modified on particular day here what i did

ls -lt|grep "Sep 24" | awk '{print $9}'|sed 's/^/@\/Users\/chakri\/projects\//g'
https://snipt.net/embed/202975296bec91de33b644019acb13a3/
https://snipt.net/raw/202975296bec91de33b644019acb13a3/
202975296bec91de33b644019acb13a3
text
Text only
3
2016-09-21T13:40:12
True
False
False
/api/public/snipt/83044/
oracle-shell
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>#I came up with a situation where i need to append @ and PATH at th starting of the all files that are modified on particular day here what i did </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>ls -lt|grep &quot;Sep 24&quot; | awk &#39;{print $9}&#39;|sed &#39;s/^/@\/Users\/chakri\/projects\//g&#39; </span></pre></div> </td></tr></table>
bash, oracle, shell

SQL

Activate HR user in Oracle

1
2
3
4
5
alter user hr identified by hr account unlock;

/*
Enter HR_ORCL for the Connection Name (or any other name that identifies your connection), hr for the Username and Password, specify your localhost for the Hostname and enter ORCL for the SID. Click Test.
*/
https://snipt.net/embed/6ef757aee1f1d547d692061435e028c7/
https://snipt.net/raw/6ef757aee1f1d547d692061435e028c7/
6ef757aee1f1d547d692061435e028c7
sql
SQL
5
2016-09-25T03:39:32
True
False
False
/api/public/snipt/41621/
activate-hr-user-in-oracle
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">alter</span> <span class="k">user</span> <span class="n">hr</span> <span class="n">identified</span> <span class="k">by</span> <span class="n">hr</span> <span class="n">account</span> <span class="n">unlock</span><span class="p">;</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="cm">/*</span> </span><span id="L-4"><a name="L-4"></a><span class="cm">Enter HR_ORCL for the Connection Name (or any other name that identifies your connection), hr for the Username and Password, specify your localhost for the Hostname and enter ORCL for the SID. Click Test.</span> </span><span id="L-5"><a name="L-5"></a><span class="cm">*/</span> </span></pre></div> </td></tr></table>
oracle, pl/sql

SQL

Find a constraint by name

1
2
3
SELECT * 
FROM all_constraints 
WHERE constraint_name='THE_CONSTRAINT';
https://snipt.net/embed/65cede35e0429ecdfec39f38adc78c26/
https://snipt.net/raw/65cede35e0429ecdfec39f38adc78c26/
65cede35e0429ecdfec39f38adc78c26
sql
SQL
3
2016-09-22T02:02:10
True
False
False
/api/public/snipt/40330/
find-a-constraint-by-name
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">SELECT</span> <span class="o">*</span> </span><span id="L-2"><a name="L-2"></a><span class="k">FROM</span> <span class="n">all_constraints</span> </span><span id="L-3"><a name="L-3"></a><span class="k">WHERE</span> <span class="k">constraint_name</span><span class="o">=</span><span class="s1">&#39;THE_CONSTRAINT&#39;</span><span class="p">;</span> </span></pre></div> </td></tr></table>
oracle, sql

SQL

Generate SQL to drop all sequences

SELECT 'DROP SEQUENCE ' || sequence_name || ';' FROM user_sequences;
https://snipt.net/embed/290328a8ee5c85ac2b0490b9f8cc7a2e/
https://snipt.net/raw/290328a8ee5c85ac2b0490b9f8cc7a2e/
290328a8ee5c85ac2b0490b9f8cc7a2e
sql
SQL
1
2016-09-25T15:51:39
True
False
False
/api/public/snipt/40329/
generate-sql-to-drop-all-sequences
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">SELECT</span> <span class="s1">&#39;DROP SEQUENCE &#39;</span> <span class="o">||</span> <span class="n">sequence_name</span> <span class="o">||</span> <span class="s1">&#39;;&#39;</span> <span class="k">FROM</span> <span class="n">user_sequences</span><span class="p">;</span> </span></pre></div> </td></tr></table>
oracle, sql

SQL

GROUP BY with Date

select to_char(date_lastmodified, 'DD.MM.YYYY'), count(*) as anz from hf_monthly_offline 
group by to_char(date_lastmodified, 'DD.MM.YYYY');
https://snipt.net/embed/9c5b39205abb1da1d2c8a198f5df8109/
https://snipt.net/raw/9c5b39205abb1da1d2c8a198f5df8109/
9c5b39205abb1da1d2c8a198f5df8109
sql
SQL
2
2016-09-25T19:02:12
True
False
False
/api/public/snipt/39809/
group-by-with-date
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">select</span> <span class="n">to_char</span><span class="p">(</span><span class="n">date_lastmodified</span><span class="p">,</span> <span class="s1">&#39;DD.MM.YYYY&#39;</span><span class="p">),</span> <span class="k">count</span><span class="p">(</span><span class="o">*</span><span class="p">)</span> <span class="k">as</span> <span class="n">anz</span> <span class="k">from</span> <span class="n">hf_monthly_offline</span> </span><span id="L-2"><a name="L-2"></a><span class="k">group</span> <span class="k">by</span> <span class="n">to_char</span><span class="p">(</span><span class="n">date_lastmodified</span><span class="p">,</span> <span class="s1">&#39;DD.MM.YYYY&#39;</span><span class="p">);</span> </span></pre></div> </td></tr></table>
oracle, sql

SQL

Extract date part

dbms_output.put_line(extract(month FROM sysdate));
https://snipt.net/embed/dd5768b743ec75f657f7c18451cb1eb0/
https://snipt.net/raw/dd5768b743ec75f657f7c18451cb1eb0/
dd5768b743ec75f657f7c18451cb1eb0
sql
SQL
1
2016-09-23T16:32:23
True
False
False
/api/public/snipt/39807/
extract-date-part
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="n">dbms_output</span><span class="p">.</span><span class="n">put_line</span><span class="p">(</span><span class="k">extract</span><span class="p">(</span><span class="k">month</span> <span class="k">FROM</span> <span class="n">sysdate</span><span class="p">));</span> </span></pre></div> </td></tr></table>
oracle, sql

SQL

Finding calendar week to given date

SELECT to_char(TO_DATE('02/08/2004', 'MM/DD/YYYY'), 'WW') FROM dual;
https://snipt.net/embed/f2b25a16ff64a9cb4362d218fc6246e4/
https://snipt.net/raw/f2b25a16ff64a9cb4362d218fc6246e4/
f2b25a16ff64a9cb4362d218fc6246e4
sql
SQL
1
2016-09-23T16:24:40
True
False
False
/api/public/snipt/39806/
finding-calendar-week-to-given-date
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">SELECT</span> <span class="n">to_char</span><span class="p">(</span><span class="n">TO_DATE</span><span class="p">(</span><span class="s1">&#39;02/08/2004&#39;</span><span class="p">,</span> <span class="s1">&#39;MM/DD/YYYY&#39;</span><span class="p">),</span> <span class="s1">&#39;WW&#39;</span><span class="p">)</span> <span class="k">FROM</span> <span class="n">dual</span><span class="p">;</span> </span></pre></div> </td></tr></table>
oracle, sql

SQL

Anonymous procedure with cursor

1
2
3
4
5
6
7
begin
declare cursor csr_period is
select * from supervisor_quest_period;  
  begin
  null;
  end;
end;
https://snipt.net/embed/b58757fe738f5571d4e5acd95c46cf42/
https://snipt.net/raw/b58757fe738f5571d4e5acd95c46cf42/
b58757fe738f5571d4e5acd95c46cf42
sql
SQL
7
2016-09-22T02:02:49
True
False
False
/api/public/snipt/39804/
anonymous-procedure-with-cursor
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">begin</span> </span><span id="L-2"><a name="L-2"></a><span class="k">declare</span> <span class="k">cursor</span> <span class="n">csr_period</span> <span class="k">is</span> </span><span id="L-3"><a name="L-3"></a><span class="k">select</span> <span class="o">*</span> <span class="k">from</span> <span class="n">supervisor_quest_period</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a> <span class="k">begin</span> </span><span id="L-5"><a name="L-5"></a> <span class="k">null</span><span class="p">;</span> </span><span id="L-6"><a name="L-6"></a> <span class="k">end</span><span class="p">;</span> </span><span id="L-7"><a name="L-7"></a><span class="k">end</span><span class="p">;</span> </span></pre></div> </td></tr></table>
oracle, sql
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.