Figure 3-6: Fixed-length strings and variable-length strings. . (Crystaltech web hosting)
Figure 3-6: Fixed-length strings and variable-length strings. . Variable-length strings A variable-length string allows storage into a datatype as the actual length of the string, as long as a maximum limit is not exceeded. The length of the string is variable because when storing a string of length less than the width specified by the datatype, the string is not padded (as is the case for fixed-length strings). Only the actual string value is stored. Storing the string XXX into a variable length string datatype of ten characters in length stores the three characters only, and not three characters padded by seven spaces. Different databases use different naming conventions for variable-length string datatypes. VARCHAR(n) or TEXT(n) are common naming formats for variable-length strings. Figure 3-6 shows variable-length strings on country names (COUNTRY), returning only the names of the countries and no padding out to maximum length as for fixed-length strings. DM returned as DM COUNTRY is variable length returning only the value in the column SQL> select country|| , ||fxcode|| , ||currency Gambia, GMD, Dalasi Ghana, GHC, Cedis Guinea, GNF, Francs Guatemala, GTQ, Quetzales Germany, DM , Deutsche Marks Guyana, GYD, Dollars COUNTRY|| , ||FXCODE|| , ||CURRENCY 2 from country 3 where fxcode is not null 4 and country like G% ; FXCODE is a fixed length, 3 character string 43 Database Modeling Building Blocks
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision web and email hosting services