Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Microsoft Windows [Version 10.0.14393]
- (c) 2016 Microsoft Corporation. Wszelkie prawa zastrzeżone.
- C:\Users\student>mysql -u daszkow1 -p -h mysql.agh.edu.pl
- Enter password: ****************
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 5952128
- Server version: 5.5.62-0+deb8u1 (Debian)
- Copyright (c) 2000, 2015, 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 daszkow1
- Database changed
- mysql> CREATE TABLE wykladowca ( id int(11) NOT NULL AUTO_INCREMENT, imie varchar(40) NOT NULL, nazwisko varchar(40) NOT NULL, email varchar(255) DEFAULT NULL, PRIMARY KEY (id)) ENGINE=InnoDB;
- ERROR 1050 (42S01): Table 'wykladowca' already exists
- mysql> CREATE TABLE przedmiot ( id int(11) NOT NULL AUTO_INCREMENT, wykladowca_id int(11) NOT NULL, nazwa varchar(80) NOT NULL, rok_akademicki varchar(10) NOT NULL,PRIMARY KEY (id), KEY wykladowca_id (wykladowca_id), CONSTRAINT przedmiot_ibfk_1 FOREIGN KEY (wykladowca_id) REFERENCES wykladowca (id) ON UPDATE CASCADE) ENGINE=InnoDB;
- Query OK, 0 rows affected (0.01 sec)
- mysql> CREATE TABLE zaliczenie ( id int(11) NOT NULL AUTO_INCREMENT, student_id int(11) NOT NULL, przedmiot_id int(11) NOT NULL, ocena decimal(5,1) NOT NULL,PRIMARY KEY (id),CONSTRAINT zaliczenie_ibfk_1FOREIGN KEY (student_id)REFERENCES student (id) ON UPDATE CASCADE,CONSTRAINT zaliczenie_ibfk_2 FOREIGN KEY (przedmiot_id) REFERENCES przedmiot (id) ON UPDATE CASCADE) 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 'KEY (student_id)REFERENCES student (id) ON UPDATE CASCADE,CONSTRAINT zaliczenie_' at line 1
- mysql> DROP TABLE if exists zaliczenie;
- Query OK, 0 rows affected, 1 warning (0.00 sec)
- mysql> CREATE TABLE zaliczenie (
- -> id int(11) NOT NULL AUTO_INCREMENT,
- -> student_id int(11) NOT NULL,
- -> przedmiot_id int(11) NOT NULL,
- -> ocena decimal (5,1) NOT NULL,
- -> PRIMARY KEY (id),
- -> CONSTRAINT zaliczenie_ibfk_1
- -> FOREIGN KEY (student_id)
- -> REFERENCES student (id)
- -> ON UPDATE CASCADE,
- -> CONSTRAINT zaliczneie_ibfk_2
- -> FOREIGN KEY (przedmiot_id)
- -> REFERENCES przedmiot (id)
- -> ON UPDATE CASCADE) ENGINE=InnoDB;
- Query OK, 0 rows affected (0.00 sec)
- mysql> select * from daszkow1;
- ERROR 1146 (42S02): Table 'daszkow1.daszkow1' doesn't exist
- mysql> select *;
- ERROR 1096 (HY000): No tables used
- mysql> selct * from zaliczenie;
- 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 'selct * from zaliczenie' at line 1
- mysql> select * from zaliczenie;
- Empty set (0.02 sec)
- mysql> LOAD DATA LOCAL INFILE 't:/lab2_przedmiot.csv' INTO TABLE przedmiot LINES TERMINATED BY '\r\n' (wykladowca_id, nazwa, rok_akademicki);
- Query OK, 0 rows affected, 1 warning (0.00 sec)
- Records: 1 Deleted: 0 Skipped: 1 Warnings: 1
- mysql> select * from przedmiot
- -> ;
- Empty set (0.00 sec)
- mysql> LOAD DATA LOCAL INFILE 't:/lab2_przedmiot.csv' INTO TABLE przedmiot LINES TERMINATED BY '\r\n' (wykladowca_id, nazwa, rok_akademicki);
- Query OK, 0 rows affected, 2 warnings (0.02 sec)
- Records: 1 Deleted: 0 Skipped: 1 Warnings: 2
- mysql> LOAD DATA LOCAL INFILE 't:/lab2_przedmiot.csv' INTO TABLE przedmiot LINES TERMINATED BY '\r\n' (wykladowca_id, nazwa, rok_akademicki);
- Query OK, 0 rows affected, 2 warnings (0.00 sec)
- Records: 1 Deleted: 0 Skipped: 1 Warnings: 2
- mysql> select * from przedmiot;
- Empty set (0.00 sec)
- mysql> LOAD DATA LOCAL INFILE 't:/lab2_przedmiot.csv' INTO TABLE przedmiot LINES TERMINATED BY '\r\n' (wykladowca_id, nazwa, rok_akademicki);
- Query OK, 0 rows affected, 6 warnings (0.00 sec)
- Records: 3 Deleted: 0 Skipped: 3 Warnings: 6
- mysql> select * from przedmiot;
- Empty set (0.00 sec)
- mysql> LOAD DATA LOCAL INFILE 't:/lab2_przedmiot.csv' INTO TABLE przedmiot FIELDS TERMINATED BY ',' LINES TERMINATED BY ';' (wykladowca_id, nazwa, rok_akademicki);
- Query OK, 0 rows affected, 6 warnings (0.00 sec)
- Records: 3 Deleted: 0 Skipped: 3 Warnings: 6
- mysql> select * from przedmiot;
- Empty set (0.00 sec)
- mysql> SOURCE t:/lab2-load-data.sql;
- Query OK, 10 rows affected (0.00 sec)
- Records: 10 Deleted: 0 Skipped: 0 Warnings: 0
- Query OK, 2 rows affected (0.02 sec)
- Records: 2 Deleted: 0 Skipped: 0 Warnings: 0
- Query OK, 3 rows affected (0.00 sec)
- Records: 3 Deleted: 0 Skipped: 0 Warnings: 0
- Query OK, 30 rows affected (0.02 sec)
- Records: 30 Deleted: 0 Skipped: 0 Warnings: 0
- mysql>
- mysql> select * from przedmiot;
- +----+---------------+----------------------------+----------------+
- | id | wykladowca_id | nazwa | rok_akademicki |
- +----+---------------+----------------------------+----------------+
- | 1 | 1 | Bazy danych | 2013/2014 |
- | 2 | 2 | In??ynieria oprogramowania | 2013/2014 |
- | 3 | 2 | Projektowanie_obiektowe | 2013/2014 |
- +----+---------------+----------------------------+----------------+
- 3 rows in set (0.00 sec)
- mysql> select * from wykladowca;
- +----+-----------+------------+----------------------------+
- | id | imie | nazwisko | email |
- +----+-----------+------------+----------------------------+
- | 1 | Pawe?? | Skrzy??ski | pawel.skrzynski@agh.edu.pl |
- | 2 | Rados??aw | Klimek | rklimek@agh.edu.pl |
- +----+-----------+------------+----------------------------+
- 2 rows in set (0.00 sec)
- mysql> show tables
- -> ;
- +--------------------+
- | Tables_in_daszkow1 |
- +--------------------+
- | przedmiot |
- | student |
- | wykladowca |
- | zaliczenie |
- +--------------------+
- 4 rows in set (0.00 sec)
- mysql> select * from student;
- +----+-----------+------------+----------------+--------------------------------+
- | id | imie | nazwisko | urodzenie_data | email |
- +----+-----------+------------+----------------+--------------------------------+
- | 1 | Jan | Nowak | 1990-01-21 | jnowak@student.agh.edu.pl |
- | 2 | Marek | Kowalski | 1990-04-16 | mkowalski@student.agh.edu.pl |
- | 3 | Piotr | Kowalczyk | 1990-03-25 | pkowalczyk@student.agh.edu.pl |
- | 4 | Ryszard | Libera | 1990-08-25 | rlibera@student.agh.edu.pl |
- | 5 | Alicja | Nowakowska | 1990-07-11 | anowakowska@student.agh.edu.pl |
- | 6 | Marta | Pietruska | 1990-03-13 | mpietruska@student.agh.edu.pl |
- | 7 | Maria | Duk | 1990-09-22 | mduk@student.agh.edu.pl |
- | 8 | Magdalena | Trawa | 1990-10-25 | mtrawa@student.agh.edu.pl |
- | 9 | Tomasz | Trawa | 1990-10-25 | ptrawa@student.agh.edu.pl |
- | 10 | Magdalena | Kieltyka | 1990-11-22 | mkieltyka@student.agh.edu.pl |
- +----+-----------+------------+----------------+--------------------------------+
- 10 rows in set (0.00 sec)
- mysql> select * from zaliczenie;
- +----+------------+--------------+-------+
- | id | student_id | przedmiot_id | ocena |
- +----+------------+--------------+-------+
- | 1 | 1 | 1 | 5.0 |
- | 2 | 2 | 1 | 5.0 |
- | 3 | 3 | 1 | 4.5 |
- | 4 | 4 | 1 | 4.5 |
- | 5 | 5 | 1 | 4.0 |
- | 6 | 6 | 1 | 4.0 |
- | 7 | 7 | 1 | 3.5 |
- | 8 | 8 | 1 | 3.5 |
- | 9 | 9 | 1 | 3.0 |
- | 10 | 10 | 1 | 2.0 |
- | 11 | 1 | 2 | 5.0 |
- | 12 | 2 | 2 | 5.0 |
- | 13 | 3 | 2 | 4.5 |
- | 14 | 4 | 2 | 4.5 |
- | 15 | 5 | 2 | 4.5 |
- | 16 | 6 | 2 | 4.5 |
- | 17 | 7 | 2 | 3.5 |
- | 18 | 8 | 2 | 3.5 |
- | 19 | 9 | 2 | 2.0 |
- | 20 | 10 | 2 | 2.0 |
- | 21 | 1 | 3 | 5.0 |
- | 22 | 2 | 3 | 5.0 |
- | 23 | 3 | 3 | 4.5 |
- | 24 | 4 | 3 | 4.5 |
- | 25 | 5 | 3 | 4.5 |
- | 26 | 6 | 3 | 4.5 |
- | 27 | 7 | 3 | 4.0 |
- | 28 | 8 | 3 | 3.5 |
- | 29 | 9 | 3 | 3.0 |
- | 30 | 10 | 3 | 3.0 |
- +----+------------+--------------+-------+
- 30 rows in set (0.00 sec)
- mysql> select * FROM zaliczenie WHERE ocena=5.0
- -> ;
- +----+------------+--------------+-------+
- | id | student_id | przedmiot_id | ocena |
- +----+------------+--------------+-------+
- | 1 | 1 | 1 | 5.0 |
- | 2 | 2 | 1 | 5.0 |
- | 11 | 1 | 2 | 5.0 |
- | 12 | 2 | 2 | 5.0 |
- | 21 | 1 | 3 | 5.0 |
- | 22 | 2 | 3 | 5.0 |
- +----+------------+--------------+-------+
- 6 rows in set (0.00 sec)
- mysql> select * FROM zaliczenie WHERE ocena=5.0 AND przedmiot_id=2
- -> ;
- +----+------------+--------------+-------+
- | id | student_id | przedmiot_id | ocena |
- +----+------------+--------------+-------+
- | 11 | 1 | 2 | 5.0 |
- | 12 | 2 | 2 | 5.0 |
- +----+------------+--------------+-------+
- 2 rows in set (0.00 sec)
- mysql> SELECT COUNT (*) from zaliczenie WHERE ocena=5.0
- -> ;
- 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 '*) from zaliczenie WHERE ocena=5.0' at line 1
- mysql> SELECT COUNT (*) from zaliczenie;
- 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 '*) from zaliczenie' at line 1
- mysql> SELECT COUNT * from zaliczenie;
- 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 'from zaliczenie' at line 1
- mysql> mysqldump
- -> ;
- 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 'mysqldump' at line 1
- mysql> count(*) from zaliczenie where ocena=5.0;
- 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 'count(*) from zaliczenie where ocena=5.0' at line 1
- mysql> select count(*) from zaliczenie where ocena=5.0;
- +----------+
- | count(*) |
- +----------+
- | 6 |
- +----------+
- 1 row in set (0.00 sec)
- mysql> select p.nazwa, count(*)
- -> from zaliczenie z, przedmiot p
- -> where z.przedmiot_id=p.id AND z.ocena=5.0
- -> GROUP BY p.nazwa;
- +----------------------------+----------+
- | nazwa | count(*) |
- +----------------------------+----------+
- | Bazy danych | 2 |
- | In??ynieria oprogramowania | 2 |
- | Projektowanie_obiektowe | 2 |
- +----------------------------+----------+
- 3 rows in set (0.00 sec)
- mysql>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement