<?xml version="1.0" encoding="UTF-8" ?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
    <title>Posteet: sql</title> 
    <link>http://www.posteet.com/</link> 
    <description>Recent posteets posted to Posteet</description>
    <ttl>60</ttl>

    
    <item>
        <title>Echappement des caractères spéciaux dans les requêtes SQL</title>
        <link>http://www.posteet.com/view/1363</link>
        <description>
        <![CDATA[<pre>Escape quotes 
Use two quotes for every one displayed. Examples: 
SQL&gt; SELECT 'Frank''s Oracle site' AS text FROM DUAL;
 TEXT
 --------------------
 Franks's Oracle site

 SQL&gt; SELECT 'A ''quoted'' word.' AS text FROM DUAL;
 TEXT
 ----------------
 A 'quoted' word.

 SQL&gt; SELECT 'A ''''double quoted'''' word.' AS text FROM DUAL;
 TEXT
 -------------------------
 A ''double quoted'' word.

Escape wildcard characters 
The LIKE keyword allows for string searches. The '_' wild card character is used to match exactly one character, while '%' is used to match zero or more occurrences of any characters. These characters can be escaped in SQL. Examples: 
SELECT name FROM emp 
 WHERE id LIKE '%/_%' ESCAPE '/';

SELECT name FROM emp 
 WHERE id LIKE '%\%%' ESCAPE '\';

Escape ampersand (&amp;) characters in SQL*Plus 
When using SQL*Plus, the DEFINE setting can be changed to allow &amp;'s (ampersands) to be used in text: 
SET DEFINE ~
SELECT 'Lorel &amp; Hardy' FROM dual;

Other methods: 
Define an escape character: 
SET ESCAPE '\'
SELECT '\&amp;abc' FROM dual;

Don't scan for substitution variables: 
SET SCAN OFF
SELECT '&amp;ABC' x FROM dual;

Use the 10g Quoting mechanism: 
Syntax
 q'[QUOTE_CHAR]Text[QUOTE_CHAR]'
 Make sure that the QUOTE_CHAR doesnt exist in the text.

SELECT q'{This is Orafaq's 'quoted' text field}' FROM DUAL;</pre> <a href="http://www.posteet.com/tags/échappement">[échappement]</a>  <a href="http://www.posteet.com/tags/SQL">[SQL]</a> ]]>        </description>
        <dc:creator>jemini_fr</dc:creator>
        <pubDate>Fri, 14 Nov 2008 09:54:11 +0000</pubDate>

            <category>échappement</category>
            <category>SQL</category>
    
    </item>

  
    <item>
        <title>highest id in table</title>
        <link>http://www.posteet.com/view/1318</link>
        <description>
        <![CDATA[<pre>SELECT MAX(id) FROM table;</pre> <a href="http://www.posteet.com/tags/lastid">[lastid]</a>  <a href="http://www.posteet.com/tags/sql">[sql]</a> ]]>        </description>
        <dc:creator>sx</dc:creator>
        <pubDate>Thu, 16 Oct 2008 08:11:21 +0000</pubDate>

            <category>lastid</category>
            <category>sql</category>
    
    </item>

  
    <item>
        <title>MySQL Query</title>
        <link>http://www.posteet.com/view/1287</link>
        <description>
        <![CDATA[<pre>define(&quot;DBNAME&quot;, &quot;db_name&quot;);
define(&quot;HOST&quot;, &quot;localhost&quot;);
define(&quot;USER&quot;, &quot;foo&quot;);
define(&quot;PASSWORD&quot;, &quot;var&quot;);

$dbconnect = mysql_connect(HOST, USER, PASSWORD);
mysql_select_db(DBNAME, $dbconnect);

$sql = 'SELECT * FROM table';
$q = mysql_query($sql, $dbconnect) or die(&quot;Error with SQL: $sql&quot;);
$num = mysql_num_rows($q);
for ($i=0; $i&lt;$num; $i++)
{
	$dbOut = mysql_fetch_assoc($q);
	echo $dbOut['col'];
}</pre> <a href="http://www.posteet.com/tags/query">[query]</a>  <a href="http://www.posteet.com/tags/sql">[sql]</a> ]]>        </description>
        <dc:creator>nox.freak</dc:creator>
        <pubDate>Fri, 26 Sep 2008 18:56:18 +0000</pubDate>

            <category>query</category>
            <category>sql</category>
    
    </item>

  
    <item>
        <title>Insérer un fichier SQL sur un serveur Apache Windows (dans Wamp ou EasyPhp)</title>
        <link>http://www.posteet.com/view/1280</link>
        <description>
        <![CDATA[<pre>Note : Dans tous les cas, ajouter l’option -p si un mot de passe est nécessaire après le nom du compte. Dans les exemples, on utilise le compte 'root'. ATTENTION : Il ne faut pas mettre d’espace entre l’option -p et le mot de passe.

Pour exporter avec l’utilitaire mysqldump.exe :

mysqldump -u root database &gt; backup-file.sql

Pour importer, cliquer &quot;démarrer/executer&quot;, puis taper ’cmd’. Ensuite lancer pour Wamp :

C:\&quot;Program Files&quot;\wamp\bin\mysql\mysql5.0.45\bin\mysql.exe -u root nom_de_la_base &lt; c:\fichier.sql</pre> <a href="http://www.posteet.com/tags/données">[données]</a>  <a href="http://www.posteet.com/tags/export">[export]</a>  <a href="http://www.posteet.com/tags/fichier">[fichier]</a>  <a href="http://www.posteet.com/tags/import">[import]</a>  <a href="http://www.posteet.com/tags/mysql">[mysql]</a>  <a href="http://www.posteet.com/tags/sql">[sql]</a> ]]>        </description>
        <dc:creator>cyo</dc:creator>
        <pubDate>Tue, 23 Sep 2008 13:33:21 +0000</pubDate>

            <category>données</category>
            <category>export</category>
            <category>fichier</category>
            <category>import</category>
            <category>mysql</category>
            <category>sql</category>
    
    </item>

  
    <item>
        <title>get the last SQL entry</title>
        <link>http://www.posteet.com/view/1241</link>
        <description>
        <![CDATA[<pre>SELECT LAST_INSERT_ID();</pre> <a href="http://www.posteet.com/tags/sql">[sql]</a> ]]>        </description>
        <dc:creator>sx</dc:creator>
        <pubDate>Wed, 03 Sep 2008 07:51:15 +0000</pubDate>

            <category>sql</category>
    
    </item>

  
    <item>
        <title>Trouver les enregistrements en doublon dans une table MySQL</title>
        <link>http://www.posteet.com/view/1008</link>
        <description>
        <![CDATA[<pre>SELECT ChampUnique
FROM MaTable
GROUP BY ChampUnique HAVING COUNT(*) &gt; 1</pre> <a href="http://www.posteet.com/tags/doublon">[doublon]</a>  <a href="http://www.posteet.com/tags/sql">[sql]</a> ]]>        </description>
        <dc:creator>cyo</dc:creator>
        <pubDate>Thu, 12 Jun 2008 14:38:27 +0000</pubDate>

            <category>doublon</category>
            <category>sql</category>
    
    </item>

  
    <item>
        <title>sqlplus dans un shell</title>
        <link>http://www.posteet.com/view/535</link>
        <description>
        <![CDATA[<pre>function sql () {
    [ $# -ne 1 ] &amp;&amp; echo &quot;Usage : sql [ fichier.sql | commande ]&quot; &amp;&amp; return 1
    if [ -f &quot;$*&quot; ]; then
        cat &quot;$*&quot; | sqlplus -s login/passwd;
    else
        echo &quot;$*&quot; | sqlplus -s login/passwd;
    fi
}</pre> <a href="http://www.posteet.com/tags/bash">[bash]</a>  <a href="http://www.posteet.com/tags/oracle">[oracle]</a>  <a href="http://www.posteet.com/tags/sql">[sql]</a>  <a href="http://www.posteet.com/tags/sqlplus">[sqlplus]</a> ]]>        </description>
        <dc:creator>yoko</dc:creator>
        <pubDate>Fri, 30 Nov 2007 23:05:16 +0000</pubDate>

            <category>bash</category>
            <category>oracle</category>
            <category>sql</category>
            <category>sqlplus</category>
    
    </item>

  
    <item>
        <title>Construct select (HTML) dynamic with any table SQL</title>
        <link>http://www.posteet.com/view/218</link>
        <description>
        <![CDATA[<pre>function selectTable($nomtable, $where = NULL, $order = NULL)
         {
            $sql = &quot;SELECT * FROM $nomtable&quot;;
            if ( $where !== NULL ) $sql .= &quot; WHERE $where&quot;;
            if ($order !== NULL)$sql.=&quot; ORDER BY $order &quot;;
            
            $query=mysql_query($sql);
            
            $ret = array();
            while ( $donnee = mysql_fetch_assoc($query))
            {
               $ret[] = $donnee;
            }
            return $ret;
         }
         
         function sqlSelect($sqlDonnee, $nomCol, $valCol)
         {
            for($i = 0 ; $i&lt;count($sqlDonnee) ; $i++)
            {
               $selectDonee[&quot;name&quot;][$i] = $sqlDonnee[$i][$nomCol];
               $selectDonee[&quot;value&quot;][$i] = $sqlDonnee[$i][$valCol];
            }
         return $selectDonee;
         }
         
         function htmlSelect($nom, $options, $selected = NULL, $css = NULL)
         {
            $select  = &quot;&lt;select name=\&quot;&quot;.htmlentities($nom).&quot;\&quot;&quot;;
            if ( $css !== NULL )
               $select .= &quot; $css&gt;&quot;;
            else
               $select .= &quot;&gt;&quot;;

            for($i = 0 ; $i&lt;count($options[&quot;name&quot;]) ; $i++)
            {
               if ( $selected !== NULL &amp;&amp; $selected == $options[&quot;value&quot;][$i] )
                  $select .= &quot;&lt;option value=\&quot;&quot;.$options[&quot;value&quot;][$i].&quot;\&quot; selected=\&quot;selected\&quot;&gt;&quot;.$options[&quot;name&quot;][$i].&quot;&lt;/option&gt;\n&quot;;
               else
                  $select .= &quot;&lt;option value=\&quot;&quot;.$options[&quot;value&quot;][$i].&quot;\&quot;&gt;&quot;.$options[&quot;name&quot;][$i].&quot;&lt;/option&gt;\n&quot;;
            }
            $select .= &quot;&lt;/select&gt;\n&quot;;

            return $select;
         }

/*** Exemple utilisation ***/
/* &lt;option selected&gt; par defaut pour le pays ayant l'id 72 */
         $paysSelect = isset($_POST[&quot;pays&quot;]) ? ($_POST[&quot;pays&quot;]) : (&quot;72&quot;);
         
         $selectPays=selectTable(&quot;pays&quot;);
         $pays=sqlSelect($selectPays,&quot;nom&quot;,&quot;id&quot;);         
         echo htmlSelect(&quot;id&quot;, $pays, $paysSelect); // on construit notre &lt;select&gt;</pre> <a href="http://www.posteet.com/tags/fonction">[fonction]</a>  <a href="http://www.posteet.com/tags/function">[function]</a>  <a href="http://www.posteet.com/tags/html">[html]</a>  <a href="http://www.posteet.com/tags/mysql">[mysql]</a>  <a href="http://www.posteet.com/tags/php">[php]</a>  <a href="http://www.posteet.com/tags/select html">[select html]</a>  <a href="http://www.posteet.com/tags/select table">[select table]</a>  <a href="http://www.posteet.com/tags/sql">[sql]</a>  <a href="http://www.posteet.com/tags/web">[web]</a> ]]>        </description>
        <dc:creator>xillon</dc:creator>
        <pubDate>Mon, 05 Nov 2007 11:52:08 +0000</pubDate>

            <category>fonction</category>
            <category>function</category>
            <category>html</category>
            <category>mysql</category>
            <category>php</category>
            <category>select html</category>
            <category>select table</category>
            <category>sql</category>
            <category>web</category>
    
    </item>

  
    <item>
        <title>connexion base MySQL en PHP</title>
        <link>http://www.posteet.com/view/15</link>
        <description>
        <![CDATA[<pre>&lt;? 
// *** Script assurant la connexion à la base utilisateurs ***// 
$serveur = &quot;localhost&quot;; // Variable correspondant au nom du serveur sur lequel est installé la base
$user = &quot;clients&quot;; // Nom d'utilisateur pour se connecter à la base
$motdepasse = &quot;toto&quot;; // Mot de passe associer à $user pour se connecter à la base
$base =&quot;clients&quot;; // Nom de la base à laquelle on effectue une connection

$connection_serveur = mysql_connect($serveur, $user, $motdepasse); // Connection à MySQL
if ($connection_serveur == 0 ) // Si la connection à mysql échoue
{
	echo &quot;Désolé la connection a $serveur est impossible.&quot;; 
	exit;	// Fin du script
}

$connection_base = mysql_select_db($base);	// Connection à la base

if (!$connection_base) //Si connection à la base impossible
{ 
echo &quot;&lt;center&gt;&lt;font color=\&quot;RED\&quot;&gt;&lt;br&gt;&quot;;
	echo &quot;Désolé, accès à la base $base impossible. &lt;br&gt;&quot;;
	echo &quot;Message de MySQL : &lt;i&gt;&lt;b&gt;&quot;.mysql_error(); // Affiche le message d'erreur généré par MySQL
	exit;  // Fin du script
	echo&quot;&lt;/font&gt;&lt;/center&gt;&quot;;
}

?&gt;</pre> <a href="http://www.posteet.com/tags/connexion">[connexion]</a>  <a href="http://www.posteet.com/tags/php">[php]</a>  <a href="http://www.posteet.com/tags/sql">[sql]</a> ]]>        </description>
        <dc:creator>neorom</dc:creator>
        <pubDate>Sun, 23 Sep 2007 19:24:41 +0000</pubDate>

            <category>connexion</category>
            <category>php</category>
            <category>sql</category>
    
    </item>

  
    <item>
        <title>Backups standard via clés ssh partagées</title>
        <link>http://www.posteet.com/view/13</link>
        <description>
        <![CDATA[<pre>#!/bin/bash

TAR_COMPRESS=&quot;tar cjvf&quot; # Commande de compression
BACKUP_EXTENSION=&quot;tar.bz2&quot; # Extension des fichiers compressés
DATE=`date '+%d-%m-%Y'`
BACKUP_ADDRESS=&quot;sav@server.org&quot;
BACKUP_DIR=&quot;/directory&quot;



echo &quot;Sauvegarde des fichiers&quot;

echo &quot;On sauvegarde et on envoie le home&quot;
cd /home
for i in `ls`
do
		$TAR_COMPRESS $i-$DATE.$BACKUP_EXTENSION /home/$i/*
		echo &quot;`date` debut scp $i&quot; &gt;&gt; /var/log/backup.log
		scp $i-$DATE.$BACKUP_EXTENSION $BACKUP_ADDRESS:$BACKUP_DIR
		echo &quot;`date` fin scp $i&quot; &gt;&gt; /var/log/backup.log
		rm -f $i-$DATE.$BACKUP_EXTENSION 
done

echo &quot;On sauvegarde et on envoie le home du root &quot;
$TAR_COMPRESS root-$DATE.$BACKUP_EXTENSION /root/
echo &quot;`date` debut scp /root&quot; &gt;&gt; /var/log/backup.log
scp root-$DATE.$BACKUP_EXTENSION $BACKUP_ADDRESS:$BACKUP_DIR
echo &quot;`date` fin scp /root&quot; &gt;&gt; /var/log/backup.log
rm -f root-$DATE.$BACKUP_EXTENSION 
echo &quot;On sauvegarde et on envoie le etc&quot;
$TAR_COMPRESS etc-$DATE.$BACKUP_EXTENSION /etc/
echo &quot;`date` debut scp /etc&quot; &gt;&gt; /var/log/backup.log
scp etc-$DATE.$BACKUP_EXTENSION $BACKUP_ADDRESS:$BACKUP_DIR
echo &quot;`date` fin scp /etc&quot; &gt;&gt; /var/log/backup.log
rm -f etc-$DATE.$BACKUP_EXTENSION 

echo &quot;On passe au dump MySQL&quot;
MYSQL_USER=&quot;root&quot; # User mySQL Ã  utiliser pour faire le dump
MYSQL_PASSWORD=&quot;pass&quot; # Mot de passe root de la base mySQL
MYSQL_HOST=&quot;localhost&quot; # Host de la base mySQL
SQL_LIST_DB=&quot;SHOW DATABASES;&quot; # Requete SQL listant toutes les bases

cd /home/backup/dumpsql
echo &quot;Dump de toutes les bases MySQL&quot;
mysqldump -p&quot;$MYSQL_PASSWORD&quot; --all-databases &gt; all-databases.$DATE.sql

echo &quot;Compression et envoie du dump&quot;
$TAR_COMPRESS  all-databases-$DATE.sql.$BACKUP_EXTENSION all-databases.$DATE.sql
echo &quot;`date` debut scp all databases&quot; &gt;&gt; /var/log/backup.log
scp all-databases-$DATE.sql.$BACKUP_EXTENSION $BACKUP_ADDRESS:$BACKUP_DIR
echo &quot;`date` fin scp all databases&quot; &gt;&gt; /var/log/backup.log
rm -f all-databases.$DATE.sql
rm -f all-databases-$DATE.sql.$BACKUP_EXTENSION

echo &quot;Dump base par base&quot;
for database in `echo $SQL_LIST_DB | mysql -u $MYSQL_USER -p&quot;$MYSQL_PASSWORD&quot; -h $MYSQL_HOST | sed 1d`
do

	mysqldump -p&quot;$MYSQL_PASSWORD&quot; --databases $database &gt; $database-$DATE.sql

	$TAR_COMPRESS $database-$DATE.sql.$BACKUP_EXTENSION $database-$DATE.sql
	rm -f $database-$DATE.sql
done

echo &quot;On sauvegarde le dump des bases et on l'envoie&quot;
$TAR_COMPRESS dump-$DATE.$BACKUP_EXTENSION *.*.sql.$BACKUP_EXTENSION
echo &quot;`date` debut scp base par base&quot; &gt;&gt; /var/log/backup.log
scp dump-$DATE.$BACKUP_EXTENSION $BACKUP_ADDRESS:$BACKUP_DIR
echo &quot;`date` fin scp base par base&quot; &gt;&gt; /var/log/backup.log
rm -f dump-$DATE.$BACKUP_EXTENSION</pre> <a href="http://www.posteet.com/tags/backup">[backup]</a>  <a href="http://www.posteet.com/tags/scp">[scp]</a>  <a href="http://www.posteet.com/tags/sql">[sql]</a>  <a href="http://www.posteet.com/tags/ssh">[ssh]</a>  <a href="http://www.posteet.com/tags/tar">[tar]</a> ]]>        </description>
        <dc:creator>neorom</dc:creator>
        <pubDate>Sun, 23 Sep 2007 19:18:15 +0000</pubDate>

            <category>backup</category>
            <category>scp</category>
            <category>sql</category>
            <category>ssh</category>
            <category>tar</category>
    
    </item>


</channel>
</rss>
