Sie sind auf Seite 1von 3

mysql> show databases;

+--------------------+
| Database |
+--------------------+
| information_schema |
| hotel |
| library |
| mysql |
| performance_schema |
| railway |
| sys |
+--------------------+
7 rows in set (0.00 sec)

mysql> create database hotel;


ERROR 1007 (HY000): Can't create database 'hotel'; database exists
mysql> use hotel;
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> create table customer


-> (cno int(5) not null auto_increment,
-> c_name varchar(20),
-> address varchar(20),
-> city varchar(10),
-> state varchar(15),
-> phone int(11),
-> card_holder varchar(20),
-> card_no varchar(16),
-> card_exp varchar(5),
-> email varchar(20),
-> primary key(cno));
Query OK, 0 rows affected (0.26 sec)

mysql> insert into customer


values(1,'puja','shivcolony','chalisgaon','maha',1234567,'milind',1224345656773456,'may25','puja@
gmail.com');
Query OK, 1 row affected (0.05 sec)

mysql> insert into customer


values(2,'nayan','khedi','jalgaon','panjab',3456729,'shantaram',45243455789336,'jan23','nayan@gma
il.com');
Query OK, 1 row affected (0.05 sec)

mysql> insert into customer


values(3,'swati','bhusawal','kokan','up',9845729,'vijay',45244528789336,'feb25','swati@gmail.com');
Query OK, 1 row affected (0.04 sec)

mysql> insert into customer


values(4,'shubham','malkapur','bhrhanpur','mp',3452679,'laksh',15563452878936,'jun24','shubham
@gmail.com');
Query OK, 1 row affected (0.33 sec)

mysql> select * from customer;


+-----+---------+------------+------------+--------+---------+-------------+------------------+----------
+-------------------+
| cno | c_name | address | city | state | phone | card_holder | card_no | card_exp | email
|
+-----+---------+------------+------------+--------+---------+-------------+------------------+----------
+-------------------+
| 1 | puja | shivcolony | chalisgaon | maha | 1234567 | milind | 1224345656773456 | may25 |
puja@gmail.com |
| 2 | nayan | khedi | jalgaon | panjab | 3456729 | shantaram | 45243455789336 | jan23 |
nayan@gmail.com |
| 3 | swati | bhusawal | kokan | up | 9845729 | vijay | 45244528789336 | feb25 |
swati@gmail.com |
| 4 | shubham | malkapur | bhrhanpur | mp | 3452679 | laksh | 15563452878936 | jun24 |
shubham@gmail.com |
+-----+---------+------------+------------+--------+---------+-------------+------------------+----------
+-------------------+
4 rows in set (0.00 sec)

mysql> create table room


-> (roomno int(5),
-> type varchar(15),
-> price int(10),
-> priceperadult int(20),
-> priceperchild int(15),
-> primary key(roomno));
Query OK, 0 rows affected (0.26 sec)

mysql> insert into room values(101,'single',500,200,100);


Query OK, 1 row affected (0.06 sec)

mysql> insert into room values(102,'ac',800,500,300);


Query OK, 1 row affected (0.05 sec)

mysql> insert into room values(103,'simple',300,300,50);


Query OK, 1 row affected (0.04 sec)

mysql> insert into room values(104,'doubleac',900,600,300);


Query OK, 1 row affected (0.05 sec)

mysql> update room


-> set type='general'
-> where roomno=101;
Query OK, 1 row affected (0.08 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from room;


+--------+----------+-------+---------------+---------------+
| roomno | type | price | priceperadult | priceperchild |
+--------+----------+-------+---------------+---------------+
| 101 | general | 500 | 200 | 100 |
| 102 | ac | 800 | 500 | 300 |
| 103 | simple | 300 | 300 | 50 |
| 104 | doubleac | 900 | 600 | 300 |
+--------+----------+-------+---------------+---------------+
4 rows in set (0.00 sec)

mysql> create table reservation


-> (roomno int(5),
-> cno int(5),
-> arrivalinfo varchar(30),
-> vacant varchar(20),
-> primary key (roomno),
-> foreign key(roomno) references room(roomno),
-> foreign key(cno) references customer(cno));
Query OK, 0 rows affected (0.82 sec)

mysql> insert into reservation values(101,1,'at12pm','yes');


Query OK, 1 row affected (0.06 sec)

mysql> insert into reservation values(102,2,'atnight1am','no');


Query OK, 1 row affected (0.51 sec)

mysql> insert into reservation values(103,3,'at1am','yes');


Query OK, 1 row affected (0.03 sec)

mysql> insert into reservation values(104,4,'morning','yes');


Query OK, 1 row affected (0.06 sec)

mysql> select * from reservation;


+--------+------+-------------+--------+
| roomno | cno | arrivalinfo | vacant |
+--------+------+-------------+--------+
| 101 | 1 | at12pm | yes |
| 102 | 2 | atnight1am | no |
| 103 | 3 | at1am | yes |
| 104 | 4 | morning | yes |
+--------+------+-------------+--------+
4 rows in set (0.00 sec)

Das könnte Ihnen auch gefallen