Sie sind auf Seite 1von 2

kashish@pesit-HP-Compaq-dx2300-Microtower:~$ clear

kashish@pesit-HP-Compaq-dx2300-Microtower:~$ mysql -u kashis -r


Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 48
Server version: 5.5.28-0ubuntu0.12.04.3 (Ubuntu)

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit
Bye
kashish@pesit-HP-Compaq-dx2300-Microtower:~$ mysql -u kashish -r
ERROR 1045 (28000): Access denied for user 'kashish'@'localhost' (using password:
NO)
kashish@pesit-HP-Compaq-dx2300-Microtower:~$ mysql -u kashish -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 50
Server version: 5.5.28-0ubuntu0.12.04.3 (Ubuntu)

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use kdb2


Database changed
mysql> create table SALESMAN(Salesmanid char(5),Name varchar(20),City
varchar(20),Commission int,primary key(Salesmanid));
Query OK, 0 rows affected (0.09 sec)

mysql> create table CUSTOMER(Customerid char(5),CustName varchar(20),City


varchar(20),Grade char(2),Salesmanid char(5),primary key(Customerid),foreign
key(Salesmanid) references SALESMAN(Salesmanid) ON DELETE CASCADE ON UPDATE
CASCADE);
Query OK, 0 rows affected (0.09 sec)

mysql>
mysql>
mysql>
mysql>
mysql>
mysql> create table ORDERS(OrdNo int,PurchaseAmt int,OrdDate date,Customerid
char(5),Salesmanid char(5),primary key(OrdNo),foreign key(Salesmanid) references
SALESMAN(Salesmanid) ON DELETE CASCADE ON UPDATE CASCADE,foreign key(Customerid)
references CUSTOMER(Customerid) ON DELETE CASCADE ON UPDATE CASCADE);
Query OK, 0 rows affected (0.11 sec)

mysql> DESC SALESMAN;


+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| Salesmanid | char(5) | NO | PRI | | |
| Name | varchar(20) | YES | | NULL | |
| City | varchar(20) | YES | | NULL | |
| Commission | int(11) | YES | | NULL | |
+------------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> DESC CUSTOMER;


+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| Customerid | char(5) | NO | PRI | | |
| CustName | varchar(20) | YES | | NULL | |
| City | varchar(20) | YES | | NULL | |
| Grade | char(2) | YES | | NULL | |
| Salesmanid | char(5) | YES | MUL | NULL | |
+------------+-------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

mysql> DESC ORDERS;


+-------------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------+------+-----+---------+-------+
| OrdNo | int(11) | NO | PRI | 0 | |
| PurchaseAmt | int(11) | YES | | NULL | |
| OrdDate | date | YES | | NULL | |
| Customerid | char(5) | YES | MUL | NULL | |
| Salesmanid | char(5) | YES | MUL | NULL | |
+-------------+---------+------+-----+---------+-------+
5 rows in set (0.00 sec)

mysql>

Das könnte Ihnen auch gefallen