Database Reference
In-Depth Information
Starting to Explore Databases
The next few chapters coverhow to create databases, add data to them, and run queries to
find interesting relationships. In this chapter, while you're logged into MySQL or MariaDB
with the mysql client, let's get familiar with the core aspects of the database system. We'll
consider a few basic concepts of databases so that you may enter a few commands within
the mysql monitor. This will help you get comfortable with the mysql client. Because you
may be in a very early stage of learning, we'll keep it simple for now.
In SQL terminology, data is always stored ina table , a term that reflects the way a user
generally views the data. In a table about movies, for example, you might see a horizontal
row about each movie, with the title as one column, and other columns to indicate more in-
formation on each movie:
+----------+--------------------+--------+
| movie_id | title | rating |
+----------+---------------------+--------+
| 1 | Casablanca | PG |
| 2 | The Impostors | R |
| 3 | The Bourne Identity | PG-13 |
+----------+--------------------+--------+
That's just a simple example. Don't try to create that table. Let's first take a look at what
you already have on your server, to see these elements. From the mysql> prompt, enter
the following and press the Enter key:
SHOW DATABASES;
The following output (or something similar) should be displayed in response:
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
First, let me mention a topic convention. MySQL is notcase sensitive when you enter
keywords such as SHOW . You could just as well enter show or even sHoW . However, the
names of databases, tables, and columns may be case sensitive, especially on an operating
system that is case sensitive, such as Mac OS X or Linux. Most topics and documentation
use all upper case letters to indicate keywords while respecting the case of the things that
you can change. We use all lower case letters for database, table, and column names be-
Search WWH ::




Custom Search