Quoting

So far we have not assigned any data values to records nor have we done comparisons between values. But we will be doing that soon so you need to know the difference in quoting. Quoting is when you supply a value to be inserted into the database or for a comparison. You need to specify if the value is a number, a character string, or a column name.

Column names can be written without any quoting or with double quotes. The column person_id can be written person_id or "person_id". Putting double quotes around a string indicates it is a column name. This gives you the ability to create column names with spaces. You could rename person_id as "person id". The double quotes also preserves case. If you name a column Person_ID it will be person_id in the output. But "Person ID" will be the same case in the output. Later, we will see how this allows you to create pretty column names for the end users.

Single quotes (apostrophes) indicate the string is a literal series of characters. So 'Bob' will literally Bob. In the next page, we will be learning how to insert data into tables. Please note that the values we insert are all enclosed in single quotes. This is very important.

The only literal data that is not in any quotes are numerics. When entering a number you just type the number such as 0, 1234, or 111.22. This is also very important. If you set a value equal to 000 it will be a number. If you enter it as '000' it is a string literal composed of three zero characters. It is not a number. If you try to treat it as a number it will cause an error.

So let us use proper quoting to insert data into tables.