0% found this document useful (0 votes)
20 views4 pages

BD

Uploaded by

Walid officiel
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)
20 views4 pages

BD

Uploaded by

Walid officiel
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/ 4

Enter password:

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


Your MySQL connection id is 11
Server version: 8.2.0 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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> show databases;


+--------------------+
| Database |
+--------------------+
| barca |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)

mysql> use barca


Database changed
mysql> create table artiste (
-> art_id bigint primary key,
-> art_nom varchar(255),
-> art_date_naissance date ,
-> ;
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 '' at
line 4
mysql> create table artiste (
-> -> art_id bigint primary key,
-> -> art_nom varchar(255),
-> -> art_date_naissance date )engine=innodb;
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 '->
art_id bigint primary key,
-> art_nom varchar(255),
-> art_date_naiss' at line 2
mysql> create table artiste (
-> art_id bigint primary key,
-> art_nom varchar(255),
-> art_date_naissance date )engine=innodb;
Query OK, 0 rows affected (0.05 sec)

mysql> desc artiste ;


+--------------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+--------------+------+-----+---------+-------+
| art_id | bigint | NO | PRI | NULL | |
| art_nom | varchar(255) | YES | | NULL | |
| art_date_naissance | date | YES | | NULL | |
+--------------------+--------------+------+-----+---------+-------+
3 rows in set (0.02 sec)
mysql> create table film (
-> film_id bigint primary key,
-> film_nom varchar(255),
-> film_annee year )engine=innodb;
Query OK, 0 rows affected (0.04 sec)

mysql> desc film;


+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| film_id | bigint | NO | PRI | NULL | |
| film_nom | varchar(255) | YES | | NULL | |
| film_annee | year | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
3 rows in set (0.01 sec)

mysql> create table film_artiste(


-> filmart_film_id bigint,
-> filmart_artiste_id bigint ,
-> filmart_type varchar(255) )engine=innodb;
Query OK, 0 rows affected (0.04 sec)

mysql> alter table film_artiste add constraint primary


key(filmart_film_id,filmart_artiste_id);
Query OK, 0 rows affected (0.11 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> desc film_artiste ;


+--------------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+--------------+------+-----+---------+-------+
| filmart_film_id | bigint | NO | PRI | NULL | |
| filmart_artiste_id | bigint | NO | PRI | NULL | |
| filmart_type | varchar(255) | YES | | NULL | |
+--------------------+--------------+------+-----+---------+-------+
3 rows in set (0.01 sec)

mysql> create table nationalite (


-> nat_film_id bigint,
-> nat_pays varchar(255) )engine=innodb;
Query OK, 0 rows affected (0.05 sec)

mysql> alter table nationalite add constraint primary key(nat_film_id,nat_pays);


Query OK, 0 rows affected (0.11 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> desc nationalite ;


+-------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| nat_film_id | bigint | NO | PRI | NULL | |
| nat_pays | varchar(255) | NO | PRI | NULL | |
+-------------+--------------+------+-----+---------+-------+
2 rows in set (0.01 sec)

mysql> alter table nationalite add constraint fk_nat_film_id foreign


key(nat_film_id) references film(film_id);
Query OK, 0 rows affected (0.26 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> desc nationalite ;


+-------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| nat_film_id | bigint | NO | PRI | NULL | |
| nat_pays | varchar(255) | NO | PRI | NULL | |
+-------------+--------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

mysql> alter table film add film_genre varchar(255);


Query OK, 0 rows affected (0.04 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> desc film ;


+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| film_id | bigint | NO | PRI | NULL | |
| film_nom | varchar(255) | YES | | NULL | |
| film_annee | year | YES | | NULL | |
| film_genre | varchar(255) | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> alter table change film_nom film_titre varchar(255) ;


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 'change
film_nom film_titre varchar(255)' at line 1
mysql> alter table film change film_nom film_titre varchar(255) ;
Query OK, 0 rows affected (0.05 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> desc film ;


+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| film_id | bigint | NO | PRI | NULL | |
| film_titre | varchar(255) | YES | | NULL | |
| film_annee | year | YES | | NULL | |
| film_genre | varchar(255) | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> alter table film modify column film_titre text ;


Query OK, 0 rows affected (0.13 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> desc film ;


+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| film_id | bigint | NO | PRI | NULL | |
| film_titre | text | YES | | NULL | |
| film_annee | year | YES | | NULL | |
| film_genre | varchar(255) | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
mysql> alter table film_artiste add constraint fk_artiste foreign
key(filmart_artiste_id)references artiste(art_id);
Query OK, 0 rows affected (0.13 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> alter table film_artiste add constraint fk_film foreign key(filmart_film_id)


references film(film_id);
Query OK, 0 rows affected (0.16 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> desc film_artiste ;


+--------------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+--------------+------+-----+---------+-------+
| filmart_film_id | bigint | NO | PRI | NULL | |
| filmart_artiste_id | bigint | NO | PRI | NULL | |
| filmart_type | varchar(255) | YES | | NULL | |
+--------------------+--------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

mysql> drop table nationalite ;


Query OK, 0 rows affected (0.05 sec)

mysql>

You might also like