Sams Teach Yourself SQL in 24 Hours, Third Edition By Ronald R. Plew, Ryan K. Stephens
Table of Contents
Hour 2. Defining Data Structures
Q&A
Q1:
How is it that I can enter numbers such as a person's Social Security number in fields defined as character fields?
A1:
Numeric values are still alphanumeric , which are allowed in character data types. Typically, the only data stored as numeric values are values used in computations . However, it may be helpful for some to define all numeric fields with a numeric data type to help control the data entered in that field.
Q2:
I still do not understand the difference between constant-length and varying-length data types. Can you explain?
A2:
Say you have an individual's last name defined as a constant data type with a length of 20 bytes. Suppose the individual's name is Smith. When the data is inserted into the table, 20 bytes are taken, 5 for the name and 15 for the extra spaces (remember that this is a constant-length data type). If you use a varying-length data type with a length of 20 and inserted Smith, only 5 bytes of space are taken.
Q3:
Are there limits on the lengths of data types?
A3:
Yes, there are limits on the lengths of data types and they do vary among the various implementations .