【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)
相关推荐
松仔log22 分钟前
JetPack——Paging3+Room
android·java·zoom
Lei活在当下6 小时前
先用起来,再理解,关于协程Coroutine应该知道的事
android·java·jvm
kernelcraft6 小时前
cuongpmyoutube-dl-android:多平台视频下载的Android客户端
android·其他
佚泽7 小时前
Android Studio 如何配置gradle
android·ide·android studio
IronMurphy7 小时前
MySQL拷打第二讲
数据库·mysql
裴东青9 小时前
ProxySQL实现MySQL主从集群的读写分离
数据库·mysql·adb
handler019 小时前
【MySQL】教你库与表的增删查改操作(基础)
运维·数据库·笔记·sql·mysql·数据·分析
苏坡余10 小时前
Android Pixel7 13.0 HAL Service 调试
android
姚不倒10 小时前
从零实现一个基于 Ollama + Go + MySQL 的 Text-to-SQL 智能体(M1 实战)
sql·mysql·云原生·golang
私人珍藏库10 小时前
【Android】AI视频剪辑-Ai剪辑视频 免费无广告
android·app·工具·软件·多功能