【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)
相关推荐
Sirens.8 小时前
MySQL表设计进阶-约束范式连接索引与事务
android·数据库·mysql
zh_xuan11 小时前
安卓上 mmap读取并修改文件内容
android·mmap
二流小码农11 小时前
鸿蒙开发:实现文本渐变效果
android·ios·harmonyos
Oo大司命oO11 小时前
藏在正则表达式里的陷阱
数据库·mysql·正则表达式
光头闪亮亮12 小时前
Fyne ( go跨平台GUI )项目实战-项目开发必备基础知识(中)
android·c++·go
光头闪亮亮12 小时前
Fyne ( go跨平台GUI )项目实战-项目开发必备基础知识(上)
android·sqlite·go
光头闪亮亮13 小时前
Fyne ( go跨平台GUI )项目实战-项目开发必备基础知识(下)
android·c++·go
Ch_champion13 小时前
2018年之前的Android 项目上使用的技术点(及第三方库)
android
龚礼鹏13 小时前
RK Android16 wifi 投屏失败问题排查
android
三十岁老牛再出发14 小时前
07.26每日总结
linux·c语言·mysql