Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

SQL

Moduli attivi nel customer portal

1
2
3
SELECT vtiger_tab.*, vtiger_customerportal_tabs.* FROM vtiger_customerportal_tabs
INNER JOIN vtiger_tab ON vtiger_tab.tabid = vtiger_customerportal_tabs.tabid
WHERE vtiger_tab.presence = 0 AND vtiger_customerportal_tabs.visible = 1
https://snipt.net/embed/09680b46a2714b627aecf0fcf06ba00f/
https://snipt.net/raw/09680b46a2714b627aecf0fcf06ba00f/
09680b46a2714b627aecf0fcf06ba00f
sql
SQL
3
2016-12-03T18:39:12
True
False
False
/api/public/snipt/145408/
moduli-attivi-nel-customer-portal
<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="n">vtiger_tab</span><span class="p">.</span><span class="o">*</span><span class="p">,</span> <span class="n">vtiger_customerportal_tabs</span><span class="p">.</span><span class="o">*</span> <span class="k">FROM</span> <span class="n">vtiger_customerportal_tabs</span> </span><span id="L-2"><a name="L-2"></a><span class="k">INNER</span> <span class="k">JOIN</span> <span class="n">vtiger_tab</span> <span class="k">ON</span> <span class="n">vtiger_tab</span><span class="p">.</span><span class="n">tabid</span> <span class="o">=</span> <span class="n">vtiger_customerportal_tabs</span><span class="p">.</span><span class="n">tabid</span> </span><span id="L-3"><a name="L-3"></a><span class="k">WHERE</span> <span class="n">vtiger_tab</span><span class="p">.</span><span class="n">presence</span> <span class="o">=</span> <span class="mi">0</span> <span class="k">AND</span> <span class="n">vtiger_customerportal_tabs</span><span class="p">.</span><span class="n">visible</span> <span class="o">=</span> <span class="mi">1</span> </span></pre></div> </td></tr></table>
cp, sql, vtiger

PostgreSQL console (psql)

Dump data from postgreSQL and compress it via gzip

psql -d news -c "\copy (select * from cnyes where newstime between '2015-1-1' and '2016-3-31') to stdout WITH (FORMAT CSV, HEADER TRUE, FORCE_QUOTE *)"  | gzip > /home/aha/cnyes.csv.gz
https://snipt.net/embed/7ecf3e734986d2ffd64027234dc64bac/
https://snipt.net/raw/7ecf3e734986d2ffd64027234dc64bac/
7ecf3e734986d2ffd64027234dc64bac
psql
PostgreSQL console (psql)
1
2016-12-05T15:17:16
True
False
False
Apr 09, 2016 at 08:30 AM
/api/public/snipt/145288/
dump-data-from-postgresql-and-compress-it-via-gzip
<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">psql</span> <span class="o">-</span><span class="n">d</span> <span class="n">news</span> <span class="o">-</span><span class="n">c</span> <span class="s s-Name">&quot;\copy (select * from cnyes where newstime between &#39;2015-1-1&#39; and &#39;2016-3-31&#39;) to stdout WITH (FORMAT CSV, HEADER TRUE, FORCE_QUOTE *)&quot;</span> <span class="o">|</span> <span class="n">gzip</span> <span class="o">&gt;</span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">aha</span><span class="o">/</span><span class="n">cnyes</span><span class="mf">.</span><span class="k">csv</span><span class="mf">.</span><span class="n">gz</span> </span></pre></div> </td></tr></table>
csv, gzip, postgresql, sql

SQL

sql Inner joins

1
2
3
4
5
SELECT crh.id, crh.date, crh.class_room_id, crh.value_dimension_one, crh.value_dimension_two, crh.value_dimension_three 
FROM class_room_histories crh 
INNER JOIN class_rooms cr ON crh.class_room_id = cr.id 
INNER JOIN teachers t ON cr.teacher_id = t.id 
where cr.teacher_id=2 AND cr.course_id=20 ORDER BY crh.date DESC
https://snipt.net/embed/7fe9326af74deb9a8e0f3ff05d1b1bcb/
https://snipt.net/raw/7fe9326af74deb9a8e0f3ff05d1b1bcb/
7fe9326af74deb9a8e0f3ff05d1b1bcb
sql
SQL
5
2016-12-07T09:11:32
True
False
False
Jan 19, 2016 at 10:11 AM
/api/public/snipt/143675/
sql-inner-joins
<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></span><span id="L-1"><a name="L-1"></a><span class="k">SELECT</span> <span class="n">crh</span><span class="p">.</span><span class="n">id</span><span class="p">,</span> <span class="n">crh</span><span class="p">.</span><span class="nb">date</span><span class="p">,</span> <span class="n">crh</span><span class="p">.</span><span class="n">class_room_id</span><span class="p">,</span> <span class="n">crh</span><span class="p">.</span><span class="n">value_dimension_one</span><span class="p">,</span> <span class="n">crh</span><span class="p">.</span><span class="n">value_dimension_two</span><span class="p">,</span> <span class="n">crh</span><span class="p">.</span><span class="n">value_dimension_three</span> </span><span id="L-2"><a name="L-2"></a><span class="k">FROM</span> <span class="n">class_room_histories</span> <span class="n">crh</span> </span><span id="L-3"><a name="L-3"></a><span class="k">INNER</span> <span class="k">JOIN</span> <span class="n">class_rooms</span> <span class="n">cr</span> <span class="k">ON</span> <span class="n">crh</span><span class="p">.</span><span class="n">class_room_id</span> <span class="o">=</span> <span class="n">cr</span><span class="p">.</span><span class="n">id</span> </span><span id="L-4"><a name="L-4"></a><span class="k">INNER</span> <span class="k">JOIN</span> <span class="n">teachers</span> <span class="n">t</span> <span class="k">ON</span> <span class="n">cr</span><span class="p">.</span><span class="n">teacher_id</span> <span class="o">=</span> <span class="n">t</span><span class="p">.</span><span class="n">id</span> </span><span id="L-5"><a name="L-5"></a><span class="k">where</span> <span class="n">cr</span><span class="p">.</span><span class="n">teacher_id</span><span class="o">=</span><span class="mi">2</span> <span class="k">AND</span> <span class="n">cr</span><span class="p">.</span><span class="n">course_id</span><span class="o">=</span><span class="mi">20</span> <span class="k">ORDER</span> <span class="k">BY</span> <span class="n">crh</span><span class="p">.</span><span class="nb">date</span> <span class="k">DESC</span> </span></pre></div> </td></tr></table>
"inner joins", sql

SQL

MySQL create user, grant privilege

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON my_db.* TO 'newuser'@'localhost';
https://snipt.net/embed/7d3ade302b050a58b4fecda7fcfa83b7/
https://snipt.net/raw/7d3ade302b050a58b4fecda7fcfa83b7/
7d3ade302b050a58b4fecda7fcfa83b7
sql
SQL
3
2016-12-06T17:01:18
True
False
False
Oct 25, 2015 at 02:38 PM
/api/public/snipt/141931/
mysql-create-user-grant-privilege
<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">CREATE</span> <span class="k">USER</span> <span class="s1">&#39;newuser&#39;</span><span class="o">@</span><span class="s1">&#39;localhost&#39;</span> <span class="n">IDENTIFIED</span> <span class="k">BY</span> <span class="s1">&#39;password&#39;</span><span class="p">;</span> </span><span id="L-2"><a name="L-2"></a><span class="k">GRANT</span> <span class="k">ALL</span> <span class="k">PRIVILEGES</span> <span class="k">ON</span> <span class="n">my_db</span><span class="p">.</span><span class="o">*</span> <span class="k">TO</span> <span class="s1">&#39;newuser&#39;</span><span class="o">@</span><span class="s1">&#39;localhost&#39;</span><span class="p">;</span> </span></pre></div> </td></tr></table>
mysql, sql

MySQL

Mysql importing errors

SET foreign_key_checks = 0;
https://snipt.net/embed/de729115ea11ac53277b45d415e8d9f9/
https://snipt.net/raw/de729115ea11ac53277b45d415e8d9f9/
de729115ea11ac53277b45d415e8d9f9
mysql
MySQL
1
2016-12-05T12:08:52
True
False
False
Mar 30, 2014 at 09:22 PM
/api/public/snipt/126066/
mysql-importing-errors
<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="kt">SET</span> <span class="n">foreign_key_checks</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> </span></pre></div> </td></tr></table>
importing, mysql, sql

SQL

SQL Alter Column Type

ALTER TABLE [MYDATABASE].[dbo].[MYTABLE] 
ALTER COLUMN UserName varchar(100)
https://snipt.net/embed/e0e7f5de4c4554ad4b1e7d3537cbce01/
https://snipt.net/raw/e0e7f5de4c4554ad4b1e7d3537cbce01/
e0e7f5de4c4554ad4b1e7d3537cbce01
sql
SQL
2
2016-12-05T07:29:00
True
False
False
Mar 03, 2014 at 10:39 AM
/api/public/snipt/118351/
sql-alter-column-type
<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">ALTER</span> <span class="k">TABLE</span> <span class="p">[</span><span class="n">MYDATABASE</span><span class="p">].[</span><span class="n">dbo</span><span class="p">].[</span><span class="n">MYTABLE</span><span class="p">]</span> </span><span id="L-2"><a name="L-2"></a><span class="k">ALTER</span> <span class="k">COLUMN</span> <span class="n">UserName</span> <span class="nb">varchar</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span> </span></pre></div> </td></tr></table>
sql, sql-change-column
Copyrighted, illegal, or inappropriate content? Email [email protected].