Files
question_db/DATABASE_Q1_hirayama;.txt
2026-10-26 16:52:18 +09:00

205 lines
9.9 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mysql> CREATE DATABASE Q1;
Query OK, 1 row affected (0.01 sec)
mysql> SHOW DATABASEs;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| q1 |
| rezodb |
| sys |
+--------------------+
6 rows in set (0.00 sec)
mysql> CREATE USER 'rezouser'@'localhost' IDENTIFIED BY 'Rezo_0000';
ERROR 1396 (HY000): Operation CREATE USER failed for 'rezouser'@'localhost'
mysql> USE Q1;
Database changed
mysql> SHOW DATABASEs;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| q1 |
| rezodb |
| sys |
+--------------------+
6 rows in set (0.01 sec)
mysql> CREATE TABLE book_table(book_id INT, book_name VARCHAR(50), author_name VARCHAR(50), price INT, sales_flag INT);
Query OK, 0 rows affected (0.03 sec)
mysql> SELECT * FROM q1;
ERROR 1146 (42S02): Table 'q1.q1' doesn't exist
mysql> SHOW tables;
+--------------+
| Tables_in_q1 |
+--------------+
| book_table |
+--------------+
1 row in set (0.00 sec)
mysql> users;
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 'users' at line 1
mysql> DESCRIBE users;
ERROR 1146 (42S02): Table 'q1.users' doesn't exist
mysql> DESCRIBE book_table;
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| book_id | int | YES | | NULL | |
| book_name | varchar(50) | YES | | NULL | |
| author_name | varchar(50) | YES | | NULL | |
| price | int | YES | | NULL | |
| sales_flag | int | YES | | NULL | |
+-------------+-------------+------+-----+---------+-------+
5 rows in set (0.01 sec)
mysql> SELECT * FROM book_table;
Empty set (0.00 sec)
mysql> INSERT INTO book_table VALUES (10001, 'TwoPeace', '三田英一郎', 420, 1);
ERROR 1054 (42S22): Unknown column ' 420' in 'field list'
mysql> INSERT INTO book_table VALUES (10001, 'TwoPeace', '三田英一郎', 420, 1);
Query OK, 1 row affected (0.00 sec)
mysql> SHOW tables;
+--------------+
| Tables_in_q1 |
+--------------+
| book_table |
+--------------+
1 row in set (0.00 sec)
mysql> SHOW book_table;
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 'book_table' at line 1
mysql> SELECT * FROM book_table;
+---------+-----------+-------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+-----------+-------------+-------+------------+
| 10001 | TwoPeace | 三田英一郎 | 420 | 1 |
+---------+-----------+-------------+-------+------------+
1 row in set (0.00 sec)
mysql> INSERT INTO book_table VALUES (10002, '名探偵金田二', '青山ふみや', 460, 1);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO book_table VALUES (20001, '坊ちゃま', '冬目漱岩', 460, 1);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO book_table VALUES (30001, '西方見聞録', '不明', 1000, 1);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO book_table VALUES (40010, '吾輩は犬である', '冬目漱岩', 420, 1);
Query OK, 1 row affected (0.00 sec)
mysql> SELECT * FROM book_table;
+---------+----------------+-------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+----------------+-------------+-------+------------+
| 10001 | TwoPeace | 三田英一郎 | 420 | 1 |
| 10002 | 名探偵金田二 | 青山ふみや | 460 | 1 |
| 20001 | 坊ちゃま | 冬目漱岩 | 460 | 1 |
| 30001 | 西方見聞録 | 不明 | 1000 | 1 |
| 40010 | 吾輩は犬である | 冬目漱岩 | 420 | 1 |
+---------+----------------+-------------+-------+------------+
5 rows in set (0.00 sec)
mysql> SELECT * FLOM book_table WHERE book_name and author_name;
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 'FLOM book_table WHERE book_name and author_name' at line 1
mysql> SELECT * FLOM book_table WHERE book_name AND author_name;
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 'FLOM book_table WHERE book_name AND author_name' at line 1
mysql> SELECT * FLOM book_table WHERE book_name AND author_name;
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 'FLOM book_table WHERE book_name AND author_name' at line 1
mysql> SELECT book_id,author_name;
ERROR 1054 (42S22): Unknown column 'book_id' in 'field list'
mysql> SELECT * FLOM 'book_table' WHERE CONCAT(book_name, author_name);
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 'FLOM 'book_table' WHERE CONCAT(book_name, author_name)' at line 1
mysql> SELECT book_name, author_name FROM book_table;
+----------------+-------------+
| book_name | author_name |
+----------------+-------------+
| TwoPeace | 三田英一郎 |
| 名探偵金田二 | 青山ふみや |
| 坊ちゃま | 冬目漱岩 |
| 西方見聞録 | 不明 |
| 吾輩は犬である | 冬目漱岩 |
+----------------+-------------+
5 rows in set (0.00 sec)
mysql> UPDATE book_table set book_id = 30001 set author_name = 'マール=コー=ポロ' set sales_flag = 0 WHERE book_name = '西方見聞録';
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 'set author_name = 'マール=コー=ポロ' set sales_flag = 0 WHERE book_na' at line 1
mysql> UPDATE book_table set book_id = 30001, author_name = 'マール=コー=ポロ', sales_flag = 0 WHERE book_name = '西方見聞録';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> SELECT * FROM book_table;
+---------+----------------+--------------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+----------------+--------------------+-------+------------+
| 10001 | TwoPeace | 三田英一郎 | 420 | 1 |
| 10002 | 名探偵金田二 | 青山ふみや | 460 | 1 |
| 20001 | 坊ちゃま | 冬目漱岩 | 460 | 1 |
| 30001 | 西方見聞録 | マール=コー=ポロ | 1000 | 0 |
| 40010 | 吾輩は犬である | 冬目漱岩 | 420 | 1 |
+---------+----------------+--------------------+-------+------------+
5 rows in set (0.00 sec)
mysql> SELECT * FROM book_table WHERE sales_flag = 1;
+---------+----------------+-------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+----------------+-------------+-------+------------+
| 10001 | TwoPeace | 三田英一郎 | 420 | 1 |
| 10002 | 名探偵金田二 | 青山ふみや | 460 | 1 |
| 20001 | 坊ちゃま | 冬目漱岩 | 460 | 1 |
| 40010 | 吾輩は犬である | 冬目漱岩 | 420 | 1 |
+---------+----------------+-------------+-------+------------+
4 rows in set (0.00 sec)
mysql> SELECT * FROM book_table WHERE book_name = '冬目漱岩' AND price = 420;
Empty set (0.00 sec)
mysql> SELECT * FROM book_table;
+---------+----------------+--------------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+----------------+--------------------+-------+------------+
| 10001 | TwoPeace | 三田英一郎 | 420 | 1 |
| 10002 | 名探偵金田二 | 青山ふみや | 460 | 1 |
| 20001 | 坊ちゃま | 冬目漱岩 | 460 | 1 |
| 30001 | 西方見聞録 | マール=コー=ポロ | 1000 | 0 |
| 40010 | 吾輩は犬である | 冬目漱岩 | 420 | 1 |
+---------+----------------+--------------------+-------+------------+
5 rows in set (0.00 sec)
mysql> SELECT * FROM book_table WHERE book_name = '冬目漱岩' AND price = 420;
Empty set (0.00 sec)
mysql> SELECT book_table WHERE book_name = '冬目漱岩' AND price = 420;
ERROR 1054 (42S22): Unknown column 'book_table' in 'field list'
mysql> SELECT * FROM book_table WHERE author_name = '冬目漱岩' AND price = 420;
+---------+----------------+-------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+----------------+-------------+-------+------------+
| 40010 | 吾輩は犬である | 冬目漱岩 | 420 | 1 |
+---------+----------------+-------------+-------+------------+
1 row in set (0.00 sec)
mysql> DELETE FROM book_table WHERE book_id = 20001;
Query OK, 1 row affected (0.01 sec)
mysql> SELECT * FROM book_table;
+---------+----------------+--------------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+----------------+--------------------+-------+------------+
| 10001 | TwoPeace | 三田英一郎 | 420 | 1 |
| 10002 | 名探偵金田二 | 青山ふみや | 460 | 1 |
| 30001 | 西方見聞録 | マール=コー=ポロ | 1000 | 0 |
| 40010 | 吾輩は犬である | 冬目漱岩 | 420 | 1 |
+---------+----------------+--------------------+-------+------------+
4 rows in set (0.00 sec)