You can use SHOW DATABASES to list all the
existing databases in the server.
mysql> SHOW
DATABASES;
+--------------------+
| Database |
+--------------------+
|
information_schema |
| mysql |
|
performance_schema |
| test |
+--------------------+
4 rows in set
(0.00 sec)
The databases "mysql", "information_schema" and "performance_schema" are system
databases used internally by MySQL. A "test" database is provided during installation for your testing.
Let us begin with a simple example - a product
sales database. A product sales database typically consists of many tables,
e.g., products, customers, suppliers, orders, payments, employees, among
others. Let's call our database "southwind" (inspired from Microsoft's Northwind Trader sample database). We
shall begin with the first table called "products" with the following columns (with the data types as indicated) and
rows:
Database: southwind
Table: products |
||||
productID
INT |
productCode
CHAR(3) |
name
VARCHAR(30) |
quantity
INT |
price
DECIMAL(10,2) |
1001
|
PEN
|
Pen Red
|
5000
|
1.23
|
1002
|
PEN
|
Pen Blue
|
8000
|
1.25
|
1003
|
PEN
|
Pen Black
|
2000
|
1.25
|
1004
|
PEC
|
Pencil 2B
|
10000
|
0.48
|
1005
|
PEC
|
Pencil 2H
|
8000
|
0.49
|
No comments:
Post a Comment