【Mysql basic commands/query: how to update the message/record data of each row】

mysql common commands

I) desc, insert and update

desc = describe,

insert into subject values(null,"Geometry Politics", 99);

sql 复制代码
mysql> select * from subject;
+------------+----------------------+---------------+
| subject_id | subject_name         | subject_hours |
+------------+----------------------+---------------+
|          1 | Communication skills |           100 |
+------------+----------------------+---------------+
1 row in set (0.00 sec)

mysql> desc subject;
+---------------+-------------+------+-----+---------+-------+
| Field         | Type        | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| subject_id    | int(11)     | YES  |     | NULL    |       |
| subject_name  | varchar(20) | YES  |     | NULL    |       |
| subject_hours | int(11)     | YES  |     | NULL    |       |
+---------------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

mysql> insert into subject values(null,"Geometry Politics", 99);
Query OK, 1 row affected (0.00 sec)

mysql> select * from subject;
+------------+----------------------+---------------+
| subject_id | subject_name         | subject_hours |
+------------+----------------------+---------------+
|          1 | Communication skills |           100 |
|       NULL | Geometry Politics    |            99 |
+------------+----------------------+---------------+
2 rows in set (0.00 sec)

mysql> update subject set subject_id = 3 where subject_hours = 99
    -> ;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from subject;
+------------+----------------------+---------------+
| subject_id | subject_name         | subject_hours |
+------------+----------------------+---------------+
|          1 | Communication skills |           100 |
|          3 | Geometry Politics    |            99 |
+------------+----------------------+---------------+
2 rows in set (0.00 sec)

mysql> describ subject;
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 'describ subject' at line 1
mysql> describe subject;
+---------------+-------------+------+-----+---------+-------+
| Field         | Type        | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| subject_id    | int(11)     | YES  |     | NULL    |       |
| subject_name  | varchar(20) | YES  |     | NULL    |       |
| subject_hours | int(11)     | YES  |     | NULL    |       |
+---------------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
相关推荐
plainGeekDev3 小时前
Glide 该换了?Coil:Kotlin 时代的图片加载库
android·开源·kotlin
小a杰.3 小时前
Ascend C编程语言进阶:高性能算子开发技巧
android·c语言·开发语言
plainGeekDev4 小时前
Android内存面试题:OOM都解决不了,性能优化从何谈起?
android·面试·kotlin
我是一颗柠檬4 小时前
【MySQL全面教学】MySQL基础SQL语句Day3(2026年)
数据库·后端·sql·mysql·oracle
MandalaO_O5 小时前
MyBatis 与 MySQL 执行流程
数据库·mysql·mybatis
JustNow_Man5 小时前
【opencode】安装使用daytona沙箱插件
android·java·javascript
键盘上的猫头鹰6 小时前
【从零学MySQL(三)】数据增删改(DML)及 SELECT 查询详解
数据库·mysql·数据分析
YIN_尹7 小时前
【Linux 系统编程】手撕一个简易版的shell命令行解释器
android·linux·运维
Cry丶7 小时前
WebFlux + R2DBC 场景下的分库分表预研:从架构选型到落地风险
mysql·postgresql·数据库架构·shardingsphere·分库分表·webflux·r2dbc