snipt

Ctrl+h for KB shortcuts

Bash Session

Do action to a find resultset

find . -name .svn -exec rm -rf {} \;
https://snipt.net/embed/0ae8cd8427eee5a5380bc0afc94279dc/
/raw/0ae8cd8427eee5a5380bc0afc94279dc/
0ae8cd8427eee5a5380bc0afc94279dc
console
Bash Session
1
2019-08-09T14:22:47
True
False
False
/api/public/snipt/42939/
do-action-to-a-find-resultset
<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></span><span id="L-1"><a name="L-1"></a><span class="go">find . -name .svn -exec rm -rf {} \;</span> </span></pre></div> </td></tr></table>
bash, shell

SQL

Find a constraint by name

1
2
3
SELECT * 
FROM all_constraints 
WHERE constraint_name='THE_CONSTRAINT';
https://snipt.net/embed/65cede35e0429ecdfec39f38adc78c26/
/raw/65cede35e0429ecdfec39f38adc78c26/
65cede35e0429ecdfec39f38adc78c26
sql
SQL
3
2019-08-16T13:51:37
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></span><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/
/raw/290328a8ee5c85ac2b0490b9f8cc7a2e/
290328a8ee5c85ac2b0490b9f8cc7a2e
sql
SQL
1
2019-08-14T03:33:16
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></span><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/
/raw/9c5b39205abb1da1d2c8a198f5df8109/
9c5b39205abb1da1d2c8a198f5df8109
sql
SQL
2
2019-08-16T08:54:29
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></span><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/
/raw/dd5768b743ec75f657f7c18451cb1eb0/
dd5768b743ec75f657f7c18451cb1eb0
sql
SQL
1
2019-08-21T00:51:00
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></span><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/
/raw/f2b25a16ff64a9cb4362d218fc6246e4/
f2b25a16ff64a9cb4362d218fc6246e4
sql
SQL
1
2019-08-15T17:52:28
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></span><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

JavaScript

Remove multiple spaces from string

myString.replace(/\s+/g, '');
https://snipt.net/embed/f44e1ba8737142e740eba3b645c2755b/
/raw/f44e1ba8737142e740eba3b645c2755b/
f44e1ba8737142e740eba3b645c2755b
js
JavaScript
1
2019-08-20T12:29:14
True
False
False
/api/public/snipt/39805/
remove-multiple-spaces-from-string
<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></span><span id="L-1"><a name="L-1"></a><span class="nx">myString</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\s+/g</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">);</span> </span></pre></div> </td></tr></table>
javscript

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/
/raw/b58757fe738f5571d4e5acd95c46cf42/
b58757fe738f5571d4e5acd95c46cf42
sql
SQL
7
2019-08-15T07:55:55
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></span><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