Saturday 16 July 2011

Database - mysql queries -part8


Enter password: *****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6 to server version: 5.0.27-community-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> Create database BookStoreSystem;
Query OK, 1 row affected (0.00 sec)

mysql> use BookStoreSystem;
Database changed
mysql> Create Table Branch
-> (Branch_Num Decimal(2) primary key,
-> Branch_name char(50),
-> Branch_Location char(50),
-> Num_Employees Decimal(2));
Query OK, 0 rows affected (0.06 sec)

mysql> Create Table Publisher
-> (Publisher_Code char(3) primary key,
-> Publisher_Name char(25),
-> City char(20));
Query OK, 0 rows affected (0.02 sec)

mysql> Create Table Author
-> (Author_Num decimal(2) primary key,
-> Author_last(12),
-> Author_last char(12),
-> Author_First char(10));
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '(12),

Author_last char(12),
Author_First char(10))' at line 3
mysql> Create Table Author
-> (Author_Num decimal(2) primary key,
-> Author_last char(12),
-> Author_First char(10));
Query OK, 0 rows affected (0.01 sec)

mysql> Create Table Book
-> (Book_Code char(4) primary key,
-> Title char (40),
-> Publisher_Code char(25),
-> Type char(3),
-> Price Decimal(4),
-> Paperback char(1));
Query OK, 0 rows affected (0.03 sec)

mysql> Create Table Wrote
-> (Book_Code char(4) primary key,
-> Author_Num Decimal(2),
-> Sequence Decimal(1));
Query OK, 0 rows affected (0.03 sec)

mysql> Create Table Inventory
-> (Book_Code char(4) primary key,
-> Branch_Num Decimal(2),
-> On_Hand Decimal(2));
Query OK, 0 rows affected (0.01 sec)

mysql> Show columns from BookStoreSystem;
ERROR 1146 (42S02): Table 'bookstoresystem.bookstoresystem' doesn't exist
mysql> show columns
-> fromBookStoreSystem;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'fromB
ookStoreSystem' at line 2
mysql> show columns
-> from BookStoreSystem;
ERROR 1146 (42S02): Table 'bookstoresystem.bookstoresystem' doesn't exist
mysql> show columns
-> from Branch;
+-----------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+-------+
| Branch_Num | decimal(2,0) | NO | PRI | | |
| Branch_name | char(50) | YES | | NULL | |
| Branch_Location | char(50) | YES | | NULL | |
| Num_Employees | decimal(2,0) | YES | | NULL | |
+-----------------+--------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> show columns
-> from Publisher;
+----------------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+----------+------+-----+---------+-------+
| Publisher_Code | char(3) | NO | PRI | | |
| Publisher_Name | char(25) | YES | | NULL | |
| City | char(20) | YES | | NULL | |
+----------------+----------+------+-----+---------+-------+
3 rows in set (0.00 sec)

mysql> show columns
-> from Author;
+--------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+-------+
| Author_Num | decimal(2,0) | NO | PRI | | |
| Author_last | char(12) | YES | | NULL | |
| Author_First | char(10) | YES | | NULL | |
+--------------+--------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

mysql> show columns
-> from Book;
+----------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+-------+
| Book_Code | char(4) | NO | PRI | | |
| Title | char(40) | YES | | NULL | |
| Publisher_Code | char(25) | YES | | NULL | |
| Type | char(3) | YES | | NULL | |
| Price | decimal(4,0) | YES | | NULL | |
| Paperback | char(1) | YES | | NULL | |
+----------------+--------------+------+-----+---------+-------+
6 rows in set (0.01 sec)

mysql> show columns
-> from Wrote;
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| Book_Code | char(4) | NO | PRI | | |
| Author_Num | decimal(2,0) | YES | | NULL | |
| Sequence | decimal(1,0) | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

mysql> show columns
-> from Inventory;
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| Book_Code | char(4) | NO | PRI | | |
| Branch_Num | decimal(2,0) | YES | | NULL | |
| On_Hand | decimal(2,0) | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
3 rows in set (0.02 sec)

mysql>

No comments:

Post a Comment