<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>blog.nicolas.pawlak.fr &#187; MySQL</title>
	<atom:link href="http://blog.nicolas.pawlak.fr/categories/bases-de-donnees/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nicolas.pawlak.fr</link>
	<description>Tux ne sait pas voler, c&#039;est normal : ce n&#039;est pas un pingouin...</description>
	<lastBuildDate>Sun, 31 Jul 2011 14:56:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Manipulations sur les adresses e-mail d&#8217;une table sur MySQL</title>
		<link>http://blog.nicolas.pawlak.fr/2011/03/05/manipulations-sur-les-adresses-e-mail-dune-table-sur-mysql/</link>
		<comments>http://blog.nicolas.pawlak.fr/2011/03/05/manipulations-sur-les-adresses-e-mail-dune-table-sur-mysql/#comments</comments>
		<pubDate>Sat, 05 Mar 2011 18:30:38 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<guid isPermaLink="false">http://blog.nicolas.pawlak.fr/?p=1374</guid>
		<description><![CDATA[Supposons un intranet d&#8217;entreprise sur un domaine &#171;&#160;domaine.fr&#160;&#187;, avec messagerie électronique en @domaine.fr pour tous les utilisateurs. Arrive le jour où l&#8217;architecture de l&#8217;intranet fait l&#8217;objet d&#8217;une évolution passant par le changement de domaine : domaine.fr devient intranet.nom.fr. Il va falloir, sur nombre de tables, modifier toutes les adresses e-mail de tous les utilisateurs. Il [...]]]></description>
			<content:encoded><![CDATA[<p>Supposons un <a href="http://www.commentcamarche.net/contents/entreprise/intranet.php3">intranet</a> d&#8217;entreprise sur un domaine &laquo;&nbsp;domaine.fr&nbsp;&raquo;, avec messagerie électronique en @domaine.fr pour tous les utilisateurs. </p>
<p>Arrive le jour où l&#8217;architecture de l&#8217;intranet fait l&#8217;objet d&#8217;une évolution passant par le changement de domaine : <em>domaine.fr</em> devient <em>intranet.nom.fr</em>. Il va falloir, sur nombre de tables, modifier toutes les adresses e-mail de tous les utilisateurs. Il faudra peut-être gérer, pour certains cas, des adresses e-mail mal orthographiées (domiane.fr), avec une <a href="http://fr.wikipedia.org/wiki/Sensibilité_à_la_casse">casse</a> différente (DOMAINE.FR), ou, comme j&#8217;ai pu le constater récemment sur un <a href="http://fr.wikipedia.org/wiki/Logiciel_de_suivi_de_problèmes"><em>bug tracker</em></a> où les utilisateurs s&#8217;inscrivaient eux-mêmes, des domaines totalement différents de celui mis en place (gmail.com)&#8230; voire pas de domaine du tout (simple nom d&#8217;utilisateur sous la forme prenom.nom) !</p>
<p>La simplicité voudrait que l&#8217;on édite le <a href="http://fr.wikipedia.org/wiki/Dump">dump</a> de la base de données avec son éditeur de texte favori (<a href="http://notepad-plus-plus.org/">Notepad++</a> sur Windows, <a href="http://fr.wikipedia.org/wiki/Vi">vi</a> sous Linux&#8230; en ce qui me concerne) et que l&#8217;on fasse les modifications avec une fonction de remplacement de texte. Seulement, l&#8217;hétérogénéité des adresses e-mail enregistrées et surtout la taille du dump sont deux freins non négligeables à cette solution. Ouvrir un dump de 1 Go avec Notepad++ ? Impensable ! Exporter uniquement les tables où figurent les adresses e-mail, puis ensuite les réinjecter ? Pourquoi pas, mais en fonction des outils mis en place sur l&#8217;intranet, cette méthode peut se réveler fastidieuse. Modifier manuellement dans la table les adresses e-mail ? Oui pour quelques utilisateurs, non pour plusieurs dizaines voire centaines d&#8217;utilisateurs.</p>
<p>Il y a une solution simple, efficace et rapide avec MySQL. Démonstration :</p>
<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">DESC</span> users;
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-------+-------------+------+-----+---------+-------+ </span>
<span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">FIELD</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">TYPE</span>        <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #66cc66;">|</span> Extra <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-------+-------------+------+-----+---------+-------+ </span>
<span style="color: #66cc66;">|</span> email <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">|</span> YES  <span style="color: #66cc66;">|</span>     <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span>    <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-------+-------------+------+-----+---------+-------+ </span>
<span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">ROW</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.05</span> sec<span style="color: #66cc66;">&#41;</span>
&nbsp;
&nbsp;
mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> users;
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-------------------------------+ </span>
<span style="color: #66cc66;">|</span> email                         <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-------------------------------+ </span>
<span style="color: #66cc66;">|</span> sergent<span style="color: #66cc66;">.</span>bellec                <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> capitaine<span style="color: #66cc66;">.</span>flamme@DOMAINE<span style="color: #66cc66;">.</span>FR   <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> lieutenant<span style="color: #66cc66;">.</span>columbo@domaine<span style="color: #66cc66;">.</span>fr <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> colonel<span style="color: #66cc66;">.</span>moutarde@youpi<span style="color: #66cc66;">.</span>fr     <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-------------------------------+ </span>
<span style="color: #cc66cc;">4</span> <span style="color: #993333; font-weight: bold;">ROWS</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.05</span> sec<span style="color: #66cc66;">&#41;</span>
&nbsp;
&nbsp;
mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">UPDATE</span> users <span style="color: #993333; font-weight: bold;">SET</span> email<span style="color: #66cc66;">=</span>concat<span style="color: #66cc66;">&#40;</span>substring_index<span style="color: #66cc66;">&#40;</span>email<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'@'</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'@intranet.nom.fr'</span><span style="color: #66cc66;">&#41;</span>;
Query OK<span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">4</span> <span style="color: #993333; font-weight: bold;">ROWS</span> affected <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.00</span> sec<span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">ROWS</span> matched: <span style="color: #cc66cc;">4</span>  Changed: <span style="color: #cc66cc;">4</span>  Warnings: <span style="color: #cc66cc;">0</span>
&nbsp;
&nbsp;
mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> users;
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">------------------------------------+ </span>
<span style="color: #66cc66;">|</span> email                              <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">------------------------------------+ </span>
<span style="color: #66cc66;">|</span> sergent<span style="color: #66cc66;">.</span>bellec@intranet<span style="color: #66cc66;">.</span>nom<span style="color: #66cc66;">.</span>fr     <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> capitaine<span style="color: #66cc66;">.</span>flamme@intranet<span style="color: #66cc66;">.</span>nom<span style="color: #66cc66;">.</span>fr   <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> lieutenant<span style="color: #66cc66;">.</span>columbo@intranet<span style="color: #66cc66;">.</span>nom<span style="color: #66cc66;">.</span>fr <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> colonel<span style="color: #66cc66;">.</span>moutarde@intranet<span style="color: #66cc66;">.</span>nom<span style="color: #66cc66;">.</span>fr   <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">------------------------------------+ </span>
<span style="color: #cc66cc;">4</span> <span style="color: #993333; font-weight: bold;">ROWS</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.00</span> sec<span style="color: #66cc66;">&#41;</span></pre></div></div>
<p>Explications :</p>
<p>- La fonction <em><a href="http://dev.mysql.com/doc/refman/5.0/fr/string-functions.html">substring_index</a></em> permet de découper la valeur d&#8217;un champ avec un délimiteur ;<br />
- La fonction <em><a href="http://dev.mysql.com/doc/refman/5.0/fr/string-functions.html">concat</a></em> permet de concaténer (ah bon ?) deux éléments.</p>
<p>Grâce à ces deux fonctions, la requête récupère pour chaque utilisateur la partie avant l&#8217;arobase, y ajoute la valeur &laquo;&nbsp;@intranet.nom.fr&nbsp;&raquo; et met à jour le champ. Tout simplement.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nicolas.pawlak.fr/2011/03/05/manipulations-sur-les-adresses-e-mail-dune-table-sur-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Utiliser des variables dans MySQL</title>
		<link>http://blog.nicolas.pawlak.fr/2010/05/08/utiliser-des-variables-dans-mysql/</link>
		<comments>http://blog.nicolas.pawlak.fr/2010/05/08/utiliser-des-variables-dans-mysql/#comments</comments>
		<pubDate>Sat, 08 May 2010 13:00:39 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[set]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[variable]]></category>
		<guid isPermaLink="false">http://blog.nicolas.pawlak.fr/?p=866</guid>
		<description><![CDATA[Dans le développement de pages web, la notion de variable est très fréquemment associée au langage de script (ASP, PHP). Mais MySQL peut en utiliser également, ce qui peut s&#8217;avérer être plus simple à administrer pour le développeur, et moins gourmand en ressources. mysql&#62; select * from t1; +------+------+ &#124; c1 &#124; c2 &#124; +------+------+ [...]]]></description>
			<content:encoded><![CDATA[<p>Dans le développement de pages web, la notion de <a href="http://fr.wikipedia.org/wiki/Variable_%28informatique%29">variable</a> est très fréquemment associée au <a href="http://fr.wikipedia.org/wiki/Langage_de_script">langage de script</a> (<a href="http://www.asp-php.net/">ASP, PHP</a>). Mais <a href="http://cyberzoide.developpez.com/php4/mysql/">MySQL</a> peut en utiliser également, ce qui peut s&#8217;avérer être plus simple à administrer pour le développeur, et moins gourmand en ressources.</p>
<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">select</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">from</span> t1<span style="color: #000033;">;</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #CC0099;">|</span> c1   <span style="color: #CC0099;">|</span> c2   <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">1</span> <span style="color: #CC0099;">|</span> aaa  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">2</span> <span style="color: #CC0099;">|</span> bbb  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">3</span> <span style="color: #CC0099;">|</span> ccc  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">4</span> <span style="color: #CC0099;">|</span> ddd  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">5</span> <span style="color: #CC0099;">|</span> eee  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #008080;">5</span> rows <span style="color: #990099; font-weight: bold;">in</span> <span style="color: #990099; font-weight: bold;">set</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.00</span> sec<span style="color: #FF00FF;">&#41;</span>
&nbsp;
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">select</span> @total <span style="color: #CC0099;">:=</span> <span style="color: #000099;">COUNT</span><span style="color: #FF00FF;">&#40;</span><span style="color: #CC0099;">*</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">as</span> <span style="color: #008000;">&quot;@total&quot;</span> <span style="color: #990099; font-weight: bold;">from</span> t1<span style="color: #000033;">;</span>
<span style="color: #CC0099;">+--------+</span>
<span style="color: #CC0099;">|</span> @total <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+--------+</span>
<span style="color: #CC0099;">|</span>      <span style="color: #008080;">5</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+--------+</span>
<span style="color: #008080;">1</span> row <span style="color: #990099; font-weight: bold;">in</span> <span style="color: #990099; font-weight: bold;">set</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.01</span> sec<span style="color: #FF00FF;">&#41;</span>
&nbsp;
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">select</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">from</span> t1 <span style="color: #990099; font-weight: bold;">where</span> c1 <span style="color: #CC0099;">=</span> @total<span style="color: #000033;">;</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #CC0099;">|</span> c1   <span style="color: #CC0099;">|</span> c2   <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">5</span> <span style="color: #CC0099;">|</span> eee  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #008080;">1</span> row <span style="color: #990099; font-weight: bold;">in</span> <span style="color: #990099; font-weight: bold;">set</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.01</span> sec<span style="color: #FF00FF;">&#41;</span></pre></div></div>
<p>Il est également possible d&#8217;affecter directement une valeur à une variable :</p>
<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">select</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">from</span> t1<span style="color: #000033;">;</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #CC0099;">|</span> c1   <span style="color: #CC0099;">|</span> c2   <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">1</span> <span style="color: #CC0099;">|</span> aaa  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">2</span> <span style="color: #CC0099;">|</span> bbb  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">3</span> <span style="color: #CC0099;">|</span> ccc  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">4</span> <span style="color: #CC0099;">|</span> ddd  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">5</span> <span style="color: #CC0099;">|</span> eee  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #008080;">5</span> rows <span style="color: #990099; font-weight: bold;">in</span> <span style="color: #990099; font-weight: bold;">set</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.00</span> sec<span style="color: #FF00FF;">&#41;</span>
&nbsp;
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">set</span> @valeur <span style="color: #CC0099;">=</span> <span style="color: #008080;">4</span><span style="color: #000033;">;</span>
Query OK<span style="color: #000033;">,</span> <span style="color: #008080;">0</span> rows affected <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.00</span> sec<span style="color: #FF00FF;">&#41;</span>
&nbsp;
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">select</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">from</span> t1 <span style="color: #990099; font-weight: bold;">where</span> c1 <span style="color: #CC0099;">=</span> @valeur<span style="color: #000033;">;</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #CC0099;">|</span> c1   <span style="color: #CC0099;">|</span> c2   <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">4</span> <span style="color: #CC0099;">|</span> ddd  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #008080;">1</span> row <span style="color: #990099; font-weight: bold;">in</span> <span style="color: #990099; font-weight: bold;">set</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.00</span> sec<span style="color: #FF00FF;">&#41;</span></pre></div></div>
<p>Notez que dans ce cas, il faut utiliser simplement le signe &laquo;&nbsp;=&nbsp;&raquo; et non &laquo;&nbsp;:=&nbsp;&raquo; comme précédemment.</p>
<p>Un exemple d&#8217;utilisation concrète : comment faire pour qu&#8217;une table aux <a href="http://fr.wikipedia.org/wiki/Cl%C3%A9_primaire">clés primaires</a> décousues (1,3,8,14,15&#8230;) soit de nouveau bien ordonnée (1,2,3,4,5&#8230;) <sup>[1]</sup> ? Sélectionner chaque entrée de la table et l&#8217;ajouter dans une autre table ? C&#8217;est lourd&#8230; Faire une <a href="http://fr.wikipedia.org/wiki/Structure_de_contr%C3%B4le#Boucles">boucle</a> et envoyer une <a href="http://www.ianywhere.com/developer/product_manuals/sqlanywhere/0901/fr/html/dbrffr9/00000498.htm">instruction UPDATE</a> pour chaque entrée de la table ? C&#8217;est lourd&#8230; </p>
<p>MySQL le fait avec seulement une variable et une requête :</p>
<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">select</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">from</span> t1<span style="color: #000033;">;</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #CC0099;">|</span> c1   <span style="color: #CC0099;">|</span> c2   <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">1</span> <span style="color: #CC0099;">|</span> aaa  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">3</span> <span style="color: #CC0099;">|</span> bbb  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">8</span> <span style="color: #CC0099;">|</span> ccc  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>   <span style="color: #008080;">14</span> <span style="color: #CC0099;">|</span> ddd  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>   <span style="color: #008080;">15</span> <span style="color: #CC0099;">|</span> eee  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #008080;">5</span> rows <span style="color: #990099; font-weight: bold;">in</span> <span style="color: #990099; font-weight: bold;">set</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.00</span> sec<span style="color: #FF00FF;">&#41;</span>
&nbsp;
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">set</span> @valeur <span style="color: #CC0099;">=</span> <span style="color: #008080;">0</span><span style="color: #000033;">;</span>
Query OK<span style="color: #000033;">,</span> <span style="color: #008080;">0</span> rows affected <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.00</span> sec<span style="color: #FF00FF;">&#41;</span>
&nbsp;
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">update</span> t1 <span style="color: #990099; font-weight: bold;">set</span> c1 <span style="color: #CC0099;">=</span> @valeur <span style="color: #CC0099;">:=</span> @valeur <span style="color: #CC0099;">+</span> <span style="color: #008080;">1</span><span style="color: #000033;">;</span>
Query OK<span style="color: #000033;">,</span> <span style="color: #008080;">4</span> rows affected <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.00</span> sec<span style="color: #FF00FF;">&#41;</span>
Rows matched: <span style="color: #008080;">5</span>  Changed: <span style="color: #008080;">4</span>  <span style="color: #990099; font-weight: bold;">Warnings</span>: <span style="color: #008080;">0</span>
&nbsp;
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">select</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">from</span> t1<span style="color: #000033;">;</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #CC0099;">|</span> c1   <span style="color: #CC0099;">|</span> c2   <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">1</span> <span style="color: #CC0099;">|</span> aaa  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">2</span> <span style="color: #CC0099;">|</span> bbb  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">3</span> <span style="color: #CC0099;">|</span> ccc  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">4</span> <span style="color: #CC0099;">|</span> ddd  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>    <span style="color: #008080;">5</span> <span style="color: #CC0099;">|</span> eee  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #008080;">5</span> rows <span style="color: #990099; font-weight: bold;">in</span> <span style="color: #990099; font-weight: bold;">set</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.00</span> sec<span style="color: #FF00FF;">&#41;</span></pre></div></div>
<p>[1] : avec un champ auto-incrémenté et des <a href="http://www.ianywhere.com/developer/product_manuals/sqlanywhere/0901/fr/html/dbrffr9/00000386.htm">instructions DELETE</a> à répétition, on a vite fait de se retrouver dans ce genre de situation.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nicolas.pawlak.fr/2010/05/08/utiliser-des-variables-dans-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Supprimer le bip système de MySQL en console sous Windows</title>
		<link>http://blog.nicolas.pawlak.fr/2010/01/13/supprimer-le-bip-systeme-de-mysql-en-console-sous-windows/</link>
		<comments>http://blog.nicolas.pawlak.fr/2010/01/13/supprimer-le-bip-systeme-de-mysql-en-console-sous-windows/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 14:30:19 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[bip]]></category>
		<guid isPermaLink="false">http://blog.nicolas.pawlak.fr/?p=385</guid>
		<description><![CDATA[L&#8217;utilisation de MySQL en console sous Windows présente un léger inconvénient dans son utilisation classique : chaque erreur provoque un bip système plutôt désagréable pour les oreilles des voisins&#8230; et les nôtres. Il existe pourtant un paramètre à passer dans la commande de lancement MySQL afin de désactiver cette fonction : -b. Ce paramètre figure [...]]]></description>
			<content:encoded><![CDATA[<p>L&#8217;utilisation de MySQL en console sous Windows présente un léger inconvénient dans son utilisation classique : chaque erreur provoque un bip système plutôt désagréable pour les oreilles des voisins&#8230; et les nôtres. </p>
<p>Il existe pourtant un paramètre à passer dans la commande de lancement MySQL afin de désactiver cette fonction : <strong>-b</strong>.</p>
<p>Ce paramètre figure dans l&#8217;aide de la commande mysql, mais semble visiblement peu connu&#8230; malgré son utilité.</p>
<p>Pensez donc à lancer MySQL de cette façon :</p>
<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">C:\<span style="color: #33cc33;">&gt;</span> mysql -b -h serveur -u identifiant -p</pre></div></div>
<p>Vos voisins vous remercieront, et vous n&#8217;aurez plus à craindre d&#8217;être agressé à chaque erreur dans votre requête SQL&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nicolas.pawlak.fr/2010/01/13/supprimer-le-bip-systeme-de-mysql-en-console-sous-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

