Page 317 - IT 402 v2.0 class 10
P. 317

N ot e s


                      Data type may vary  depending on the database.  For example, MySQL supports INT but Oracle supports
                      Data type may vary depending on the database. For example, MySQL supports INT but Oracle supports
                                        depending on the database.
                                                                 For example, MySQL supports INT but Oracle supports
                      Data type may vary
                      NUMBER for integer values.
                      NUMBER for integer values.
            Some of the data types in SQL are listed below:
                    DATA TYPE                                       DESCRIPTION
                 INTEGER               Integer number  no decimal

                            n           haracter string with fixed length of n.
                          n            Character string with variable length of n.
                    IM    p s          Where ‘p’ is precision value and ‘s’ is scale value.

                 DATE                  Stores YY/MM/DD values.
                 F O    p              Where ‘p’ is precision value

                 TIME                  Stores hour, minute and second values.
                 TIMESTAMP             Stores year, month, day, hour, minute and second values.

            S     erators

            SQL statements consist of reserved words or characters used to perform arithmetical operations, comparisons,
            etc. These reserved words or characters are called as ‘Operators’.
            The three types of operators in SQL are:

            S    rit metic   erators


                    OPERATORS                                        DESCRIPTION
                         ‘+’            Performs addition.
                         ‘-’            Performs subtraction.

                         ‘*’            Performs multiplication.
                          ‘/’           Performs division.

                         ‘%’            Divides left-hand operand by right-hand operand and returns remainder

            S    om arison   erators

            Consider the value of a=25 and b=75 to understand examples in the following table.

                 OPERATORS                             DESCRIPTION                                   MP
                                 Checks if value of ‘a’ is equal to value of ‘b’. If yes,
                      ‘=’                                                                    a b  is false.
                                 condition becomes true, else false.
                                 Checks if value of ‘a’ is not equal to value of ‘b’. If yes,
                      ‘!=’                                                                   a  b  is true.
                                 condition becomes true, else false.
                                 Checks if value of ‘a’ is equal to value of ‘b’ or not. If yes,
                     ‘<>’                                                                    a  b  is true.
                                 condition becomes true, else false.
                                 Checks if value of ‘a’ is greater than value of ‘b’. If yes,
                      ‘>’                                                                    a b  is false.
                                 condition becomes true, else false.


                                                                                       More on Database        315
   312   313   314   315   316   317   318   319   320   321   322