« MySQL/NULL » : différence entre les versions

Contenu supprimé Contenu ajouté
Page créée avec « {{MySQL}} Null is a special logical value in SQL. Most programming languages have 2 values of logic: True and False. SQL also has NULL which means "Unknown". A NULL value... »
 
Aucun résumé des modifications
Ligne 1 :
{{MySQL}}
 
De nombreux langages de programmation ont deux valeurs logiques : <code>True</code> et <code>False</code>. SQL en possède une troisième pour les valeurs inconnue : <code>NULL</code>.
Null is a special logical value in SQL. Most programming languages have 2 values of logic: True and False. SQL also has NULL which means "Unknown". A NULL value can be set.
 
<code>NULL</code> étant une absence de valeur, il peut être assigné à des colonnes <code>TEXT</code>, <code>INTEGER</code> ou autres. Toutefois une colonne déclarée <code>NOT NULL</code> ne pourra pas en contenir.
NULL is a non-value, so it can be assigned to TEXT columns, INTEGER columns or any other datatype. A column can not contain NULLs only if it has been declared as NOT NULL (see ALTER TABLE).
 
<source lang="mysql">
Ligne 13 :
("Jonny", "Five", NULL, "Binary");
</source>
<code>NULL</code> ne doit pas être entouré d'apostrophes ou de guillemets, ou bien il désignera une chaine de caractère contenant son nom.
Do not quote the NULL. If you quote a Null then you name the person NULL.
For some strange reason, NULLs do not show visually on windows XP in Varchar fields but they do in Fedora's version, so versions of mysql can give different outputs. Here we set the value of Sting and Homer's first name to a zero length string "", because we KNOW they have NO first name, but we KNOW we do not know the place they were born. To check for a NULLs use
<source lang="mysql">