Page 27 - 2617_JSSPS_C-8
P. 27

Some of the data types in SQL are listed below:


                                     Data Type                            Description

                               CHAR                     Specifies a fixed length string
                               VARCHAR                  Specifies a variable length string

                               INT or INTEGER           Specifies an integer number

                               FLOAT                    Specifies a floating-point number

                               DOUBLE                   Specifies a normal-size floating point number

                               DATE                     Specifies a date value in YYYY-MM-DD format

                               TIME                     Specifies a time value in HH:MM:SS format
                               BOOL or BOOLEAN          Specifies a Boolean value


                 SQL OPERATORS


                 SQL statements consist of reserved symbols or characters used to perform arithmetical operations,
                 comparisons, etc. These reserved words or characters are called as ‘Operators’.

                 Some commonly used operators in SQL are:

                    Arithmetic Operators: +, –, *, /, %

                    Relational Operators: =,  !=, <>, <, >, <=, >=

                    Logical Operators: ALL, AND, ANY, BETWEEN, NOT, OR, LIKE, IN, EXISTS


                 CREATING A DATABASE

                 The  CREATE DATABASE  command  is  used  to  create a database in  MySQL.  The  syntax  to  create a
                 database is:

                      CREATE DATABASE database_name;
                 For example,

                      CREATE DATABASE School;

                 After creating a database, you need to access the database by using the USE command in the following
                 way:
                      USE School;


                 CREATING A TABLE

                 As you know that a table is a collection of organised data in the form of rows and columns. It is also
                 known as a relation. The CREATE TABLE command is used to create a table in SQL.








                                                                                           Introduction to MySQL    25
   22   23   24   25   26   27   28   29   30   31   32