Page 257 - Information_Practice_Fliipbook_Class11
P. 257

For example, for the attribute type DECIMAL(6,2), the value 1234.56789 may be rounded to 1234.57
                   or truncated to 1234.56. If an attribute of  DECIMAL type is assigned a value whose integer part has more
                   digits than the permitted, the system may assign the maximum (or minimum) allowed value. For example,
                   given the DECIMAL(6,2)specification, the number -12345 may be stored as -9999.99. However,
                   MySQL will raise an error and reject the out-of-range values if strict SQL mode is enabled.  Examples of type
                   DECIMAL(6,2)
                   Valid

                   1234
                   -123456
                   1234.56
                   1234.56789            (rounded to  1234.57)
                   -1234.56789           (rounded to  -1234.57)
                   Invalid

                   Possible Value
                   12345                               (more than four digits in the integer part)   9999.99
                   12345.12              (more than four digits in the integer part)   9999.99

                   12345678.1            (more than four digits in the integer part)   9999.99
                   –12345.1234           (more than four digits in the integer part)   -9999.99
                   –12345678.12          (more than four digits in the integer part)   -9999.99


                  DECIMAL(L, D): Fixed point decimal, with total L digits and D digits after decimal.


                d.  FLOAT(p): The data type FLOAT(p) denotes the floating point numbers. The argument p denotes precision.
                   If the value of p is in the range  0 to 23, it denotes a single-precision (4-byte) floating-point value.  If the value
                   of p is in the range  24 to 53, it denotes a double-precision (8-byte) floating-point value.
                   Some of the valid examples of type FLOAT(8) are mentioned below:

                   Valid
                   1234
                   -123456

                   1234.56
                   1234.56789            (rounded to  1234.57)
                   -1234.56789           (rounded to  -1234.57)



                  FLOAT(p): Floating point number.


            2.  Character:
                a.  CHAR(L) or CHARACTER(L): The data type CHAR(L)denotes fixed-length character strings. The argument
                   L denotes the length of the string and the unused spaces are filled with blanks. For example, if we declare
                   Emp_Name of an employee to be of type CHAR(15), then the name string 'SMITA KALA' will be expanded
                   to 'SMITA KALA     '. If the length of a string of type CHAR is not specified, the default length is 1. If
                   the length of a string is more than the specified length, the trailing characters will be truncated. Next, we give
                   some valid and invalid examples of type CHAR(10)



                                                                Database Concepts and the Structured Query Language  243
   252   253   254   255   256   257   258   259   260   261   262