Page 148 - Informatics_Practices_Fliipbook_Class12
P. 148

Character


                     Subtype               Width              Valid examples                 Invalid examples

         CHAR(L) or CHARACTER(L)           L       For type CHAR(10)                     For type CHAR(10)
         Fixed-length        character

         strings of length L.                      'IIIT Delhi'  is  stored  as  'IIIT  110016
                                                   Delhi'                                29-01-2022



                                                   'IIT' is stored as 'IIT       '       Note:  both  the  above
                                                                                         examples are not a string

                                                   Note: in both of the above examples, the
                                                   number  of  bytes  required  to  store  the
                                                   data is 10 bytes.

         VARCHAR(L)                        <=L     'IIIT Delhi'  is  stored  as  'IIIT  For type CHAR(10)
         Variable-length character                 Delhi'
         strings of length upto L.
                                                                                         110016
                                                   'IIT' is stored as 'IIT'              29-01-2022


                                                   Note that, each string above require one   Note:  both  the  above
                                                   byte more than the length of the string.   examples are not a string
                                                   Therefore, the string 'IIIT Delhi'
                                                   will need 11 bytes, whereas 'IIT' need
                                                   4 bytes in memory.

        DATE




               DATE: The standard date format is YYYY-MM-DD.


        The data type DATE denotes a date. The standard date format is YYYY-MM-DD. However, SQL also permits other
        formats like DD-MM-YYYY for storing and retrieving dates.




               TIME: The data type TIME denotes time. It supports various time formats such as HH:MM: SS, HH-MM-SS, HH.MM
               AM/PM.



        4.4 SQL Statements and Functions

        This section will discuss several SQL statements and functions for defining and manipulating data.  Each SQL statement
        terminates with a semicolon.

        4.4.1 CREATE DATABASE statement

        Creating a database is the first step in database management. CREATE DATABASE statement creates a database. The
        syntax for the CREATE DATABASE statement is as follows:

               CREATE DATABASE database_name;

          134  Touchpad Informatics Practices-XII
   143   144   145   146   147   148   149   150   151   152   153