Page 69 - 2611_SmartGPT Pro V(5.0) C-8
P. 69

This will display all tables in the ‘School’ database.










                                                                         Create a Books table with BookID, Title,
                                                                      Author and Price columns. Set BookID as the
                                                                                     PRIMARY KEY.



                 VIEWING STRUCTURE OF A TABLE
                 To view the structure (schema) of an existing table, you can use the DESCRIBE or DESC command.
                 This shows the columns in the table, their data types and other details like Null, Key, Default and Extra.

                 The syntax to DESCRIBE command is as follows:

                 DESCRIBE table_name;
                 or

                 DESC table_name;
                 The command to view the structure of the Students table is as follows:



















                 DELETING A TABLE
                 To delete a table in MySQL, you can use the DROP TABLE command. This command permanently
                 removes the table and all its data.

                 The syntax of DROP TABLE command is as follows:

                 DROP TABLE table_name;




                           INSERTING DATA INTO TABLES

                 After creating a table, you can add records using the INSERT command. There are two ways to
                 insert data into a table.







                                                                                          MySQL: My First Database  67
   64   65   66   67   68   69   70   71   72   73   74