In my previous post we discussed on Creating a Table and viewing the structure of the Table.
Now if you want to delete an existing Table, just type in the below command.
DROP TABLE myAddressBook;
Caution: DROP TABLE command not only deletes your current table but also will delete the data stored in it. So think twice before using the command.
In our example we don’t have any data inserted into our table, so lets go ahead and delete our table myAddressBook.
Type the below command to make sure that the TABLE myAddressBook is really deleted. Don’t worry as this is our human tendency to double check often..!! :)
SHOW TABLES;
The above command will list the available tables in our database. In our case we don’t have one, hence an empty set will be returned.
You can also verify by executing the below command.
DESC myAddressBook;
On executing the above command, we should be able to see an error message notifying that this table doesn't exist.
Lets go back to our MySQL command line client and execute the above commands.
Note: Whenever starting your command line client for the first time, make sure to select the right database first. ex: use testers_db;
In my next post, I shall write about Inserting data into a Table, before that here is a small activity, all you have to do is re-create the same table i.e. myAddressBook again, for details refer to my previous post.
Now if you want to delete an existing Table, just type in the below command.
DROP TABLE myAddressBook;
Caution: DROP TABLE command not only deletes your current table but also will delete the data stored in it. So think twice before using the command.
In our example we don’t have any data inserted into our table, so lets go ahead and delete our table myAddressBook.
Type the below command to make sure that the TABLE myAddressBook is really deleted. Don’t worry as this is our human tendency to double check often..!! :)
SHOW TABLES;
The above command will list the available tables in our database. In our case we don’t have one, hence an empty set will be returned.
You can also verify by executing the below command.
DESC myAddressBook;
On executing the above command, we should be able to see an error message notifying that this table doesn't exist.
Lets go back to our MySQL command line client and execute the above commands.
Note: Whenever starting your command line client for the first time, make sure to select the right database first. ex: use testers_db;
In my next post, I shall write about Inserting data into a Table, before that here is a small activity, all you have to do is re-create the same table i.e. myAddressBook again, for details refer to my previous post.
Drop a TABLE
Reviewed by Suntaragali The Smart Techie
on
December 18, 2012
Rating:
No comments: