0% found this document useful (0 votes)
51 views3 pages

Nouveau Text Document

The document shows the steps to connect to a MySQL database, drop and create a database called "compagnie_aerienne", create tables for planes, pilots, and flights, and perform some queries. It connects to MySQL, drops and recreates the database, creates tables for planes with fields for ID, name, capacity and location, pilots with ID and name fields, and flights with fields linking to planes and pilots plus date fields. Some data is inserted and selected from the planes table.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views3 pages

Nouveau Text Document

The document shows the steps to connect to a MySQL database, drop and create a database called "compagnie_aerienne", create tables for planes, pilots, and flights, and perform some queries. It connects to MySQL, drops and recreates the database, creates tables for planes with fields for ID, name, capacity and location, pilots with ID and name fields, and flights with fields linking to planes and pilots plus date fields. Some data is inserted and selected from the planes table.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.


Your MySQL connection id is 15 to server version: 5.0.27-community-nt

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

mysql>
mysql> drop database compagnie_aerienne if exists;
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 'if
exists' at line 1
mysql> drop database compagnie_aerienne if exist;
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 'if
exist' at line 1
mysql> drop database compagnie_aerienne if not exist;
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 'if not
exist' at line 1
mysql> drop database compagnie_aerienne;
Query OK, 2 rows affected (3.78 sec)

mysql> show databases;


+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| phpmyadmin |
| test |
+--------------------+
4 rows in set (0.00 sec)

mysql> create database compagnie_aerienne;


Query OK, 1 row affected (0.02 sec)

mysql> use compagnie_aerienne;


Database changed
mysql> create table avion(id_a int(10) not null primary key auto_increment, nom_a
varchar(30) not null, capacite int(10) not null, localite varchar(30) not
null)engine=innodb;
Query OK, 0 rows affected (0.10 sec)

mysql> describe avion;


+----------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+----------------+
| id_a | int(10) | NO | PRI | NULL | auto_increment |
| nom_a | varchar(30) | NO | | | |
| capacite | int(10) | NO | | | |
| localite | varchar(30) | NO | | | |
+----------+-------------+------+-----+---------+----------------+
4 rows in set (0.02 sec)

mysql> create table pilote(id_p int(10) not null primary key auto_increment, nom_p
varchar(30) not null, insert into avion values (100,'AIRBUS',300,'RABAT');
Query OK, 1 row affected (0.07 sec)

mysql> insert into avion values (101,'B737',250,'CASA');


Query OK, 1 row affected (0.07 sec)adresse text(40) not null)engine=innodb;
Query OK, 0 rows affected (0.41 sec)

mysql> create table vol(num_v int(10) not null primary key auto_increment, num_p
int(10) not null, num_a int(10) not null, vd varchar(100) not null, va varchar(100)
not null, hd datetime not null, ha datetime not null, constraint fk_nom_p foreign
key(num_p) references pilote(id_p), constraint fk_nom_a foreign key(num_a)
references avion(id_a)) engine=innodb;
Query OK, 0 rows affected (0.21 sec)

mysql> insert into avion values (102,'B737',220,'RABAT');


Query OK, 1 row affected (0.07 sec)
mysql> select * from avion;
+------+--------+----------+----------+
| id_a | nom_a | capacite | localite |
+------+--------+----------+----------+
| 100 | AIRBUS | 300 | RABAT |
| 101 | B737 | 250 | CASA |
| 102 | B737 | 220 | RABAT |
+------+--------+----------+----------+
mysql> select id_a, nom_a from avion;
+------+--------+
| id_a | nom_a |
+------+--------+
| 100 | AIRBUS |
| 101 | B737 |
| 102 | B737 |
+------+--------+
3 rows in set (0.00 sec)

mysql> select localite from avion;


+----------+
| localite |
+----------+
| RABAT |
| CASA |
| RABAT |
+----------+
3 rows in set (0.00 sec)

mysql> select localite from avion where localite='RABAT';


+----------+
| localite |
+----------+
| RABAT |
| RABAT |
+----------+
2 rows in set (0.00 sec)

mysql> select localite from avion where localite='CASA';


+----------+
| localite |
+----------+
| CASA |
+----------+
1 row in set (0.00 sec)

mysql>mysql> select distinct localite from avion;


+----------+
| localite |
+----------+
| RABAT |
| CASA |
+----------+

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy