SQL Queries - Notes
SQL Queries - Notes
1.
In a database, null means ‘nothing’, absolutely nothing. Like a vacuum or a void. This
means that it does not, in actuality (despite what a column says), have a data type (e.g.
string, integer etc.) and no functions can be called on it. E.g. we can’t SUM it or check it’s
length with the len() function in Tableau. An error would be raised if we tried. Null is simply
the word used to show the absence of any data in that field.
EMPTY
Empty on the other hand looks like nothing but is not actually nothing. Empty is really an
empty string, so something like this:
Therefore empty does have a data type (string) and therefore functions can be called on
them. For example if we were to call the len() function on an empty, the function would
execute and the result would be ‘0’.
Empty cannot exist with other data types either. For example, an 'empty’ integer would
instead contain the value 0.
Lets look at the difference between Null and Empty as given below:
In table you can see column phoneNo1 have a null value while PhoneNo2 have
an empty value .
As you know Null value is considered as unknown value and memory is not allocated for it
while Empty value is value with empty and memory allocated for it.
Lets check the length for these fields in bytes using Datalength function.
UNIQUE CONSTRAINT:
FROM information_schema.table_constraints
WHERE table_name='student'
CHECK Constarint
Again, need to know the name to delet it