Page 153 - Informatics_Practices_Fliipbook_Class12
P. 153

Dept_No SMALLINT,

                        CHECK(Gender = 'M' OR Gender = 'F' OR Gender='O'),
                   CHECK(Salary BETWEEN 8000 AND 100000)
            );#EMPLOYEE
            4.4.5 DESCRIBE TABLE

            The SQL statement DESCRIBE (or DESC in short) is used to show the structure of a database table. The syntax of the
            DESCRIBE statement is as follows:
                   DESCRIBE table_name;
                   or

                   DESC table_name;
            On executing the statement:

            DESCRIBE EMPLOYEE;
            SQL will respond as follows:


                                 Field       Type        Null      Key       Default       Extra
                               ID         int(11)      NO        PRI      NULL

                               FName      varchar(20)  NO                 NULL
                               LName      varchar(20)  NO                 NULL

                               Gender     Char(1)      NO                 NULL
                               Address    varchar(30)  YES                NULL

                               City       varchar(20)  YES                NULL
                               Pin_Code   Char(6)      YES                NULL

                               DOB        data         YES                NULL
                               Salary     int(11)      NO                 NULL

                               Dept_No    smallint(6)  YES                NULL

            4.4.6 SHOW TABLES statement

            Having created all the tables, we can use the following SQL statement to show the list of tables created in the database
            COMPANY as follows:


            SHOW TABLES;
            On executing the above statement, SQL will display the list of tables (see Table 4.2) as follows:

                                                      Tables_in_Company

                                                      department
                                                      employee

                                                      project
                                                      works_on

                                                Table 4.2: Result of DESCRIBE statement


                                                                                        Database Query using SQL  139
   148   149   150   151   152   153   154   155   156   157   158