Apr 8, 2011
After installing the required software components to properly utilize MySQL for our learning, we will now begin to discover what databases and tables are. We will also create our database and tables so that we will have our ‘scratchpad’ during the course.
By the way the word ‘schema’ is synonym to ‘database’. In the world of MySQL the ‘schema’ is just a folder that is created on the ‘C:Program FilesMySQLMySQL Server 5.0data’ directory. In the video below, we will try to create a database by way of creating a folder.
This is not the usual way of creating databases. But you will notice later that if you want to ‘preserve’ the way you want the name of your database to look like, create your database using the method discussed previously. You can try it for yourself. You will notice that every database you create, the name always come in ‘lower case’ letters.
Now, let’s see how to create database the more usual way. And there are two ways of doing this. Using MySQL Browser and using the ‘mysql’ commandline tool.
We have seen that it’s easy to create database using the GUI tool. While on the other hand, you have to know how to build SQL statements. Here, the SQL statement used is ‘CREATE DATABASE <database name>;’. And to check if it’s successful we use ‘SHOW DATABASES;’ to display all schema. Let’s dissect the ‘CREATE’ command.
CREATE – is the SQL command
DATABASE – is a reserve word
<database name> – a user supplied parameter, if there are spaces between enclosed it with (`) backticks
; – command terminator, it is required that every SQL command should end with ‘;’
To delete a database we use ‘DROP DATABASE <database name>;’. And I know that you can now be able to distinguish the ‘SQL command’ from ‘keywords’, parameters etc.
Note: Just for the purpose of this tutorial and future MySQL videos we will be using the format ‘<parameter name>’ to tell us that it is a user supplied input. SQL commands and reserve words will be presented in ‘upper’ case format and the parameters in ‘lower’ case format.