SQL Learning

SQL – CONSTRAINT

Constraint can be used to restrict the data stored in an instance of a database. Only valid instance will be stored in the database if it satisfies all constrain conditions stated on the database schema.  Example of constraints – PRIMARY… Read More ›

SQL – CAST

Similar to CONVERT function, CAST is also particularly useful to transform a data type to another type. For instance, you have a value of 20180521 for a variable named DateKey.  Again, we will need to transform this to a varchar… Read More ›

SQL – CONVERT

Convert function can be used to change data type.  One particularly good and useful example is to use this function to convert integer to varchar before converting to date – for instance, you have a value of 20180521 for a… Read More ›

SQL – Constraints

Constraint can be applied to specify rules on a database. There are many constraints but we will only discuss the most commonly used in this blog post. PRIMARY KEY  This serves as a unique identifier for each observation in a… Read More ›