【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)
相关推荐
得物技术36 分钟前
破解gh-ost变更导致MySQL表膨胀之谜|得物技术
数据库·后端·mysql
Java水解1 小时前
【MySQL】从零开始学习MySQL:基础与安装指南
后端·mysql
ace望世界5 小时前
android的Parcelable
android
顾林海5 小时前
Android编译插桩之AspectJ:让代码像特工一样悄悄干活
android·面试·性能优化
叽哥5 小时前
Flutter Riverpod上手指南
android·flutter·ios
循环不息优化不止5 小时前
安卓开发设计模式全解析
android
诺诺Okami5 小时前
Android Framework-WMS-层级结构树
android
沢田纲吉5 小时前
🗄️ MySQL 表操作全面指南
数据库·后端·mysql
alexhilton16 小时前
面向开发者的系统设计:像建筑师一样思考
android·kotlin·android jetpack
Java水解1 天前
Mysql查看执行计划、explain关键字详解(超详细)
后端·mysql