Before jumping into a practical approach of
creating a database and using it further for creating tables, let us first try
to understand what is a Database?
Let’s get started with a simple definition of a
Database.
"A Database is a container, which stores a
collection of data that can be easily retrieved, managed & updated".
Whenever we search online for some information,
do shopping online, book an air ticket or bus ticket or a train ticket etc a
database will be queried at the background for information.
How are the data stored in the Database?
A database contains tables. The information
inside the database is stored in the form of a structured data in a table which
is organized in columns and rows.
Creating a DATABASE
Note: I will be using MySQL to execute the SQL
commands.
Without wasting our time, let us start
creating our first database. If you already have MySQL installed on your
side, open the MySQL Command Line Client from the start
menu. Now type in the below command to create a database called testers_db.
CREATE DATABASE testers_db;
We have just created a testers_db database. I
would also like to know if there are any other databases available, so what
should I do to view the list of databases?
If you want to view the list of available
databases, just type in the below command.
SHOW databases;
Now that we have seen how to create a database
and how to display the list of available databases, do you think that, Are we
good to store the required information? Naah… Not yet..!! J
Though we are able to see the list of databases,
before actually storing or creating a TABLE we need to make use of a specific
database.
Remember DATABASE is a container, to store a
TABLE (data); I need to select the container first. J
Let us make use of the testers_db database to
store the information. Type in the below command to make the testers_db as the
active database.
USE testers_db;
We have created a Database, viewed the list of
available databases and used a specific database to create a table. In my next
article I shall write about Creating a Table. Keep watching this
space for more information.
BTW, do you think a Database will hold only one
Table information? Let me know your opinion in the form of
comments.
Creating and using a Database in MySQL
Reviewed by Suntaragali The Smart Techie
on
December 16, 2012
Rating:
No comments: