软件3班20240429

本文详细记录了在MySQL5.7服务器上通过命令行进行数据库连接、切换、查看表结构、执行SQL插入、更新和删除操作的过程,展示了基本的数据管理操作和错误处理。
摘要由CSDN通过智能技术生成

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -h 120.77.240.10 -P 3306 -u yanyu -p
Enter password: ********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5858
Server version: 5.7.18 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| soft01             |
| soft02             |
| soft03             |
| sys                |
| yanyu              |
+--------------------+
8 rows in set (0.01 sec)

mysql> use soft03
Database changed
mysql> show tables;
Empty set (0.01 sec)

mysql>
mysql>
mysql>
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| soft01             |
| soft02             |
| soft03             |
| sys                |
| yanyu              |
+--------------------+
8 rows in set (0.01 sec)

mysql> use soft03
Database changed
mysql> select databse();
ERROR 1305 (42000): FUNCTION soft03.databse does not exist
mysql> select database();
+------------+
| database() |
+------------+
| soft03     |
+------------+
1 row in set (0.01 sec)

mysql> show tables;
+------------------+
| Tables_in_soft03 |
+------------------+
| cao              |
| user             |
| user01           |
| user02           |
| user07           |
| user10           |
| user12           |
| user13           |
| user20           |
| user22           |
| user25           |
| user26           |
| user32           |
| user36           |
| user44           |
| user50           |
| user51           |
| user58           |
+------------------+
18 rows in set (0.01 sec)

mysql> desc user1;
ERROR 1146 (42S02): Table 'soft03.user1' doesn't exist
mysql> desc user01;
+-------+--------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| id    | int(11)      | NO   |     | NULL    |       |
| name  | varchar(255) | YES  |     | NULL    |       |
+-------+--------------+------+-----+---------+-------+
2 rows in set (0.02 sec)

mysql> insert into user01 values(
    -> 'aad','wefre');
ERROR 1366 (HY000): Incorrect integer value: 'aad' for column 'id' at row 1
mysql> insert into user01 values(
    -> 1,'yanyu');
Query OK, 1 row affected (0.01 sec)

mysql> select * from user01;
+----+-------+
| id | name  |
+----+-------+
|  1 | yanyu |
|  1 | yanyu |
+----+-------+
2 rows in set (0.01 sec)

mysql> select * from user01;
+----+-------+
| id | name  |
+----+-------+
|  1 | yanyu |
|  1 | yanyu |
+----+-------+
2 rows in set (0.01 sec)

mysql> update user01 set name = 'yanyu666';
Query OK, 2 rows affected (0.01 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql> select * from user01;
+----+----------+
| id | name     |
+----+----------+
|  1 | yanyu666 |
|  1 | yanyu666 |
+----+----------+
2 rows in set (0.01 sec)

mysql> insert into user01 values(
    -> 100,'yanyu');
Query OK, 1 row affected (0.02 sec)

mysql> select * from user01;
+-----+----------+
| id  | name     |
+-----+----------+
|   1 | yanyu666 |
|   1 | yanyu666 |
| 100 | yanyu    |
+-----+----------+
3 rows in set (0.01 sec)

mysql> update user01 set name = 'yanyu123';
Query OK, 3 rows affected (0.01 sec)
Rows matched: 3  Changed: 3  Warnings: 0

mysql> select * from user01;
+-----+----------+
| id  | name     |
+-----+----------+
|   1 | yanyu123 |
|   1 | yanyu123 |
| 100 | yanyu123 |
+-----+----------+
3 rows in set (0.01 sec)

mysql> update user01 set name = 'yanyu666'where id = 100;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from user01;
+-----+----------+
| id  | name     |
+-----+----------+
|   1 | yanyu123 |
|   1 | yanyu123 |
| 100 | yanyu666 |
+-----+----------+
3 rows in set (0.01 sec)

mysql> delete * from user01;
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 user01' at line 1
mysql> delete from user01;
Query OK, 3 rows affected (0.01 sec)

mysql> select * from user01;
Empty set (0.01 sec)

mysql> insert into user01 values(
    -> 1,'yanyu1');
Query OK, 1 row affected (0.01 sec)

mysql> insert into user01 values(
    -> 2,'yanyu66');
Query OK, 1 row affected (0.01 sec)

mysql> select * from user01;
+----+---------+
| id | name    |
+----+---------+
|  1 | yanyu1  |
|  2 | yanyu66 |
+----+---------+
2 rows in set (0.01 sec)

mysql> delete from user01 where id = 1;
Query OK, 1 row affected (0.01 sec)

mysql> select * from user01;
+----+---------+
| id | name    |
+----+---------+
|  2 | yanyu66 |
+----+---------+
1 row in set (0.01 sec)

mysql>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值