0% found this document useful (0 votes)
11 views

Create Database

Uploaded by

nyeliablaise
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Create Database

Uploaded by

nyeliablaise
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, 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 21

Server version: 8.0.36 MySQL Community Server - GPL

Copyright (c) 2000, 2024, 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> CREATE DATABASE ecole;


Query OK, 1 row affected (0.14 sec)

mysql> SHOW DATABASES;


+--------------------+

| Database |

+--------------------+

| ecole |

| information_schema |

| mysql |

| performance_schema |

| sys |

+--------------------+

5 rows in set (0.00 sec)

mysql> USE ecole;

Database changed

mysql> show tables;

Empty set (0.39 sec)

mysql> create table etudiant(


-> Num_etudiant INT NOT NULL AUTO_INCREMENT PRIMARY KEY,

-> Nom varchar(1OO),

-> prenom varchar(100),

-> Num_filiere int not null);


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 '1OO),

prenom varchar(100),

Num_filiere int not null)' at line 3

mysql> Num_filiere int not null);

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 'Num_filiere int not null)' at line 1

mysql> CREATE TABLE etudiant(


-> Num_etudiant INT NOT NULL AUTO_INCREMENT PRIMARY KEY,

-> Nom varchar(50),

-> Prenom varchar(50),

-> Poids INT NOT NULL,

-> Num_filiere INT NOT NULL);

Query OK, 0 rows affected (2.23 sec)

mysql> describe etudiant;


+--------------+-------------+------+-----+---------+----------------+

| Field | Type | Null | Key | Default | Extra |

+--------------+-------------+------+-----+---------+----------------+

| Num_etudiant | int | NO | PRI | NULL | auto_increment |

| Nom | varchar(50) | YES | | NULL | |

| Prenom | varchar(50) | YES | | NULL | |

| Poids | int | NO | | NULL | |

| Num_filiere | int | NO | | NULL | |

+--------------+-------------+------+-----+---------+----------------+

5 rows in set (0.00 sec)

mysql> INSERT INTO etudiant VALUE(1,'NYELIA','BLAISE','67','Informatique');

ERROR 1366 (HY000): Incorrect integer value: 'Informatique' for column 'Num_filiere' at row 1

mysql> INSERT INTO etudiant VALUE(1,'NYELIA','BLAISE','67','001');

Query OK, 1 row affected (0.71 sec)


mysql> desc etudiant;
+--------------+-------------+------+-----+---------+----------------+

| Field | Type | Null | Key | Default | Extra |

+--------------+-------------+------+-----+---------+----------------+

| Num_etudiant | int | NO | PRI | NULL | auto_increment |

| Nom | varchar(50) | YES | | NULL | |

| Prenom | varchar(50) | YES | | NULL | |

| Poids | int | NO | | NULL | |

| Num_filiere | int | NO | | NULL | |

+--------------+-------------+------+-----+---------+----------------+

5 rows in set (0.00 sec)

mysql> select * from etudiant;


+--------------+--------+--------+-------+-------------+

| Num_etudiant | Nom | Prenom | Poids | Num_filiere |

+--------------+--------+--------+-------+-------------+

| 1 | NYELIA | BLAISE | 67 | 1|

+--------------+--------+--------+-------+-------------+

1 row in set (0.00 sec)

mysql> INSERT INTO etudiant value(2,'MAVINGA','Esther','70','2');

Query OK, 1 row affected (0.53 sec)

mysql> select * from etudiant;


+--------------+---------+--------+-------+-------------+

| Num_etudiant | Nom | Prenom | Poids | Num_filiere |

+--------------+---------+--------+-------+-------------+

| 1 | NYELIA | BLAISE | 67 | 1|
| 2 | MAVINGA | Esther | 70 | 2|

+--------------+---------+--------+-------+-------------+

2 rows in set (0.00 sec)

mysql> SELECT * FROM etudiant WHERE Num_etudiant=2;


+--------------+---------+--------+-------+-------------+

| Num_etudiant | Nom | Prenom | Poids | Num_filiere |

+--------------+---------+--------+-------+-------------+

| 2 | MAVINGA | Esther | 70 | 2|

+--------------+---------+--------+-------+-------------+

1 row in set (0.00 sec)

mysql>

You might also like