<?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>Le blog de jsd03 &#187; SQL</title>
	<atom:link href="https://blog.developpez.com/jsd03/pcategory/bdd/oracle/oracle-sql/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.developpez.com/jsd03</link>
	<description></description>
	<lastBuildDate>Mon, 07 Nov 2016 14:34:06 +0000</lastBuildDate>
	<language>fr-FR</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.42</generator>
	<item>
		<title>Filtrage non égalitaire avec Oracle</title>
		<link>https://blog.developpez.com/jsd03/p11745/bdd/filtrage-non-egalitaire-avec-oracle</link>
		<comments>https://blog.developpez.com/jsd03/p11745/bdd/filtrage-non-egalitaire-avec-oracle#comments</comments>
		<pubDate>Tue, 29 Jan 2013 09:36:18 +0000</pubDate>
		<dc:creator><![CDATA[jsd03]]></dc:creator>
				<category><![CDATA[Base de données]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[filtrage]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/jsd03/?p=58</guid>
		<description><![CDATA[Ce titre d&#8217;article semble bateau au premier abord mais il me semble essentiel de parler de cette expérience pour le moins &#171;&#160;étrange&#160;&#187; avec un filtre sur j&#8217;ai effectué sur Oracle ces jours-ci. Le filtre suivant : 1WHERE maColonne != 'uneValeur' &#8230; <a href="https://blog.developpez.com/jsd03/p11745/bdd/filtrage-non-egalitaire-avec-oracle">Lire la suite <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Ce titre d&rsquo;article semble bateau au premier abord mais il me semble essentiel de parler de cette expérience pour le moins &laquo;&nbsp;étrange&nbsp;&raquo; avec un filtre sur j&rsquo;ai effectué sur Oracle ces jours-ci.<br />
<span id="more-58"></span><br />
Le filtre suivant :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">WHERE maColonne != 'uneValeur'</div></td></tr></tbody></table></div>
<p>renvoi, contrairement à ce que j&rsquo;aurai pensé, toutes les lignes de ma table dont la colonne &laquo;&nbsp;maColonne&nbsp;&raquo; est différente de &lsquo;uneValeur&rsquo; (jusque là tout va bien) <strong>mais également</strong> les lignes où &laquo;&nbsp;maColonne&nbsp;&raquo; IS NULL !</p>
<p>Et oui il semblerait qu&rsquo;il faille rajouter</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">OR maColonne IS NOT NULL</div></td></tr></tbody></table></div>
<p>Exemple :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">SELECT *<br />
FROM<br />
(<br />
&nbsp; &nbsp; SELECT null as maColonne<br />
&nbsp; &nbsp; FROM dual<br />
&nbsp; &nbsp; &nbsp; &nbsp; UNION <br />
&nbsp; &nbsp; SELECT 'uneValeur'<br />
&nbsp; &nbsp; FROM dual<br />
&nbsp; &nbsp; &nbsp; &nbsp; UNION<br />
&nbsp; &nbsp; SELECT 'uneAutreValeur'<br />
&nbsp; &nbsp; FROM dual<br />
)<br />
where maColonne != 'uneValeur'</div></td></tr></tbody></table></div>
<p>Renvoi une seule ligne alors que</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">SELECT *<br />
FROM<br />
(<br />
&nbsp; &nbsp; SELECT null as maColonne<br />
&nbsp; &nbsp; FROM dual<br />
&nbsp; &nbsp; &nbsp; &nbsp; UNION <br />
&nbsp; &nbsp; SELECT 'uneValeur'<br />
&nbsp; &nbsp; FROM dual<br />
&nbsp; &nbsp; &nbsp; &nbsp; UNION<br />
&nbsp; &nbsp; SELECT 'uneAutreValeur'<br />
&nbsp; &nbsp; FROM dual<br />
)<br />
where (maColonne != 'uneValeur'<br />
OR maColonne IS NULL)</div></td></tr></tbody></table></div>
<p>renvoi bien deux lignes&#8230;</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ajouter une année à une date</title>
		<link>https://blog.developpez.com/jsd03/p11726/bdd/ajouter-une-annee-a-une-date</link>
		<comments>https://blog.developpez.com/jsd03/p11726/bdd/ajouter-une-annee-a-une-date#comments</comments>
		<pubDate>Wed, 16 Jan 2013 21:12:23 +0000</pubDate>
		<dc:creator><![CDATA[jsd03]]></dc:creator>
				<category><![CDATA[Base de données]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[ajouter]]></category>
		<category><![CDATA[année]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[interval]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/jsd03/?p=53</guid>
		<description><![CDATA[Pour ajouter une année à une date on aurait tendance à faire : 1select sysdate + 365 AS ANNEE_SUP from dual; Ou : 1select ADD_MONTHS(sysdate, 12) AS ANNEE_SUP from dual; Mais en fin de compte la bonne syntaxe est : &#8230; <a href="https://blog.developpez.com/jsd03/p11726/bdd/ajouter-une-annee-a-une-date">Lire la suite <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Pour ajouter une année à une date on aurait tendance à faire :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">select sysdate + 365 AS ANNEE_SUP from dual;</div></td></tr></tbody></table></div>
<p>Ou :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">select ADD_MONTHS(sysdate, 12) AS ANNEE_SUP from dual;</div></td></tr></tbody></table></div>
<p>Mais en fin de compte la bonne syntaxe est :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">select sysdate + interval '1' year AS ANNEE_SUP &nbsp;from dual;</div></td></tr></tbody></table></div>
<p><span id="more-53"></span><br />
Effectivement :</p>
<ul>
<li>la première solution suivant si on se place dans une année bissextile ou pas ne fonctionnera pas</li>
<li>la seconde solution de ce que j&rsquo;ai pu en lire sur un site officiel Oracle ne marche pas non plus à tous les coups encore une fois à cause de ces années bissextiles&#8230;</li>
<li>du coup ajouter un intervalle fonctionnel à 100% ! alors surtout quand vous voulez ajouter une année à une date utiliser &laquo;&nbsp;interval&nbsp;&raquo; !</li>
</ul>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Création et alimentation d&#8217;une dimension DATE</title>
		<link>https://blog.developpez.com/jsd03/p11721/bdd/creation-et-alimentation-dune-dimension-date</link>
		<comments>https://blog.developpez.com/jsd03/p11721/bdd/creation-et-alimentation-dune-dimension-date#comments</comments>
		<pubDate>Tue, 15 Jan 2013 22:20:57 +0000</pubDate>
		<dc:creator><![CDATA[jsd03]]></dc:creator>
				<category><![CDATA[Base de données]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[dimension]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/jsd03/?p=26</guid>
		<description><![CDATA[Lors de la création d&#8217;un entrepôt de données, bien souvent, il contient une dimension DATE contenant la liste des dates depuis l&#8217;année 1900 jusqu&#8217;à l&#8217;année 2999. Cette table contenant plusieurs attributs comme par exemple : La date au format date &#8230; <a href="https://blog.developpez.com/jsd03/p11721/bdd/creation-et-alimentation-dune-dimension-date">Lire la suite <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Lors de la création d&rsquo;un entrepôt de données, bien souvent, il contient une dimension DATE contenant la liste des dates depuis l&rsquo;année 1900 jusqu&rsquo;à l&rsquo;année 2999. Cette table contenant plusieurs attributs comme par exemple :</p>
<ul>
<li>La date au format date</li>
<li>La date au format chaine de caractère sous la forme DD/MM/YYYY</li>
<li>La date au format numérique sous la forme YYYYMMDD</li>
<li>Le jour de l&rsquo;année</li>
<li>&#8230;</li>
</ul>
<p>Voici donc un exemple de création de DIM_DATE en Oracle.<br />
<span id="more-26"></span><br />
Tout d&rsquo;abord la description de la DIM_DATE :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">create table DIM_DATE<br />
(<br />
&nbsp; &nbsp;ID_DATE &nbsp; &nbsp; &nbsp; &nbsp;NUMBER(8) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;not null,<br />
&nbsp; &nbsp;DATE_DU_JOUR &nbsp; &nbsp; &nbsp; &nbsp; DATE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; not null,<br />
&nbsp; &nbsp;ANNEE_CALENDAIRE &nbsp; &nbsp; NUMBER(4),<br />
&nbsp; &nbsp;SEMESTRE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NUMBER(1),<br />
&nbsp; &nbsp;LIBELLE_SEMESTRE &nbsp; &nbsp; VARCHAR2(250 CHAR),<br />
&nbsp; &nbsp;TRIMESTRE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NUMBER(1),<br />
&nbsp; &nbsp;LIBELLE_TRIMESTRE &nbsp; &nbsp;VARCHAR2(250 CHAR),<br />
&nbsp; &nbsp;ANNEE_MOIS &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NUMBER(6),<br />
&nbsp; &nbsp;MOIS &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NUMBER(2),<br />
&nbsp; &nbsp;LIBELLE_MOIS &nbsp; &nbsp; &nbsp; &nbsp; VARCHAR2(250 CHAR),<br />
&nbsp; &nbsp;SEMAINE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NUMBER(2),<br />
&nbsp; &nbsp;JOUR &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NUMBER(2),<br />
&nbsp; &nbsp;LIBELLE_JOUR &nbsp; &nbsp; &nbsp; &nbsp; VARCHAR2(250 CHAR),<br />
&nbsp; &nbsp;JOUR_FERIE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CHAR(3 CHAR),<br />
&nbsp; &nbsp;JOUR_OUVRE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CHAR(3 CHAR),<br />
&nbsp; &nbsp;QUANTIEME_JOUR &nbsp; &nbsp; &nbsp; NUMBER<br />
);</div></td></tr></tbody></table></div>
<p>Et son chargement avec un simple ordre INSERT et une requête SELECT hiérarchique :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">INSERT INTO DIM_DATE (ID_DATE, DATE_DU_JOUR, ANNEE_CALENDAIRE, SEMESTRE, LIBELLE_SEMESTRE, TRIMESTRE, LIBELLE_TRIMESTRE, ANNEE_MOIS,MOIS, LIBELLE_MOIS, SEMAINE, JOUR, LIBELLE_JOUR, JOUR_FERIE, JOUR_OUVRE, QUANTIEME_JOUR)<br />
SELECT<br />
&nbsp; &nbsp; TO_NUMBER(TO_CHAR(DT_CAL, 'YYYYMMDD')) AS ID_CALENDRIER,<br />
&nbsp; &nbsp; DT_CAL AS DATE_DU_JOUR,<br />
&nbsp; &nbsp; TO_NUMBER(TO_CHAR(DT_CAL, 'YYYY')) AS ANNEE_CALENDAIRE,<br />
&nbsp; &nbsp; ROUND(TO_NUMBER(TO_CHAR(DT_CAL, 'Q'))/2) AS SEMESTRE,<br />
&nbsp; &nbsp; CASE ROUND(TO_NUMBER(TO_CHAR(DT_CAL, 'Q'))/2) WHEN 1 THEN '1er semestre' ELSE '2ème semestre' END AS LIBELLE_SEMESTRE,<br />
&nbsp; &nbsp; TO_NUMBER(TO_CHAR(DT_CAL, 'Q')) AS TRIMESTRE,<br />
&nbsp; &nbsp; CASE TO_NUMBER(TO_CHAR(DT_CAL, 'Q')) WHEN 1 THEN '1er trimestre' ELSE TO_NUMBER(TO_CHAR(DT_CAL, 'Q')) || 'ème trimestre' END AS LIBELLE_TRIMESTRE,<br />
&nbsp; &nbsp; TO_NUMBER(TO_NUMBER(TO_CHAR(DT_CAL, 'YYYY')) || LPAD(TO_CHAR(DT_CAL, 'MM'), 2, '0')) AS ANNEE_MOIS,<br />
&nbsp; &nbsp; TO_NUMBER(TO_CHAR(DT_CAL, 'MM')) AS MOIS,<br />
&nbsp; &nbsp; TO_CHAR(DT_CAL, 'Month') AS LIBELLE_MOIS,<br />
&nbsp; &nbsp; TO_NUMBER(TO_CHAR(DT_CAL, 'IW')) AS SEMAINE,<br />
&nbsp; &nbsp; TO_NUMBER(TO_CHAR(DT_CAL, 'DD')) AS JOUR,<br />
&nbsp; &nbsp; TO_CHAR(DT_CAL, 'Day') AS LIBELLE_JOUR,<br />
&nbsp; &nbsp; CASE WHEN TO_CHAR(DT_CAL, 'D') IN ('6', '7') THEN 'Oui' ELSE 'Non' END AS JOUR_FERIE,<br />
&nbsp; &nbsp; CASE WHEN TO_CHAR(DT_CAL, 'D') IN ('6', '7') THEN 'Non' ELSE 'Oui' END AS JOUR_OUVRE,<br />
&nbsp; &nbsp; NUM_JOUR AS QUANTIEME_JOUR<br />
FROM<br />
(<br />
&nbsp; &nbsp; SELECT to_date('19000101','YYYYMMDD') + (rownum - 1) AS DT_CAL, rownum AS NUM_JOUR<br />
&nbsp; &nbsp; FROM dual<br />
&nbsp; &nbsp; connect BY to_date('19000101','YYYYMMDD') + (rownum - 1) &amp;lt;= to_date(&amp;#039;29991231&amp;#039;,&amp;#039;YYYYMMDD&amp;#039;)<br />
);<br />
&nbsp;<br />
COMMIT;</div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
