linux下mysql数据库编程练习_MySQL
程序员文章站
2022-06-08 18:34:15
...
mysql> use company;
Database changed
mysql> create table worker (nid INT UNIQUE,name VARCHAR(20), address VARCHAR(200), salary float, level int);
Query OK, 0 rows affected (0.18 sec)
mysql> insert worker values (100, 'tom','beijing',2000.0,0);
Query OK, 1 row affected (0.14 sec)
mysql> insert worker values (101, 'jim','shanghai',2000.0,1);
Query OK, 1 row affected (0.01 sec)
mysql> insert worker values (102, 'mali','shanghai',3000.0,2);
Query OK, 1 row affected (0.00 sec)
mysql> select * from worker;
+------+------+----------+--------+-------+
| nid | name | address | salary | level |
+------+------+----------+--------+-------+
| 100 | tom | beijing | 2000 | 0 |
| 101 | jim | shanghai | 2000 | 1 |
| 102 | mali | shanghai | 3000 | 2 |
+------+------+----------+--------+-------+
3 rows in set (0.00 sec)
mysql> delete from woker where nid = 100;
ERROR 1146 (42S02): Table 'company.woker' doesn't exist
mysql> delete from worker where nid = 100;
Query OK, 1 row affected (0.07 sec)
mysql> select * from worker;
+------+------+----------+--------+-------+
| nid | name | address | salary | level |
+------+------+----------+--------+-------+
| 101 | jim | shanghai | 2000 | 1 |
| 102 | mali | shanghai | 3000 | 2 |
+------+------+----------+--------+-------+
2 rows in set (0.00 sec)
mysql> update worker set level = 2, salary=3000.0 where nid=101;
Query OK, 1 row affected (0.12 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from worker;
+------+------+----------+--------+-------+
| nid | name | address | salary | level |
+------+------+----------+--------+-------+
| 101 | jim | shanghai | 3000 | 2 |
| 102 | mali | shanghai | 3000 | 2 |
+------+------+----------+--------+-------+
2 rows in set (0.00 sec)
Database changed
mysql> create table worker (nid INT UNIQUE,name VARCHAR(20), address VARCHAR(200), salary float, level int);
Query OK, 0 rows affected (0.18 sec)
mysql> insert worker values (100, 'tom','beijing',2000.0,0);
Query OK, 1 row affected (0.14 sec)
mysql> insert worker values (101, 'jim','shanghai',2000.0,1);
Query OK, 1 row affected (0.01 sec)
mysql> insert worker values (102, 'mali','shanghai',3000.0,2);
Query OK, 1 row affected (0.00 sec)
mysql> select * from worker;
+------+------+----------+--------+-------+
| nid | name | address | salary | level |
+------+------+----------+--------+-------+
| 100 | tom | beijing | 2000 | 0 |
| 101 | jim | shanghai | 2000 | 1 |
| 102 | mali | shanghai | 3000 | 2 |
+------+------+----------+--------+-------+
3 rows in set (0.00 sec)
mysql> delete from woker where nid = 100;
ERROR 1146 (42S02): Table 'company.woker' doesn't exist
mysql> delete from worker where nid = 100;
Query OK, 1 row affected (0.07 sec)
mysql> select * from worker;
+------+------+----------+--------+-------+
| nid | name | address | salary | level |
+------+------+----------+--------+-------+
| 101 | jim | shanghai | 2000 | 1 |
| 102 | mali | shanghai | 3000 | 2 |
+------+------+----------+--------+-------+
2 rows in set (0.00 sec)
mysql> update worker set level = 2, salary=3000.0 where nid=101;
Query OK, 1 row affected (0.12 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from worker;
+------+------+----------+--------+-------+
| nid | name | address | salary | level |
+------+------+----------+--------+-------+
| 101 | jim | shanghai | 3000 | 2 |
| 102 | mali | shanghai | 3000 | 2 |
+------+------+----------+--------+-------+
2 rows in set (0.00 sec)
上一篇: Pygame(十)作业
推荐阅读
-
linux下mysql5.7.17最新稳定版本安装教程
-
MySQL 数据库两台主机同步实战(linux)
-
Linux 初始化MySQL 数据库报错解决办法
-
解决Windows10下mysql5.5数据库命令行中文乱码问题
-
Mac环境下php操作mysql数据库的方法分享
-
Linux下查看nginx apache mysql php的编译参数
-
centos6.5 Linux下用安装包方式安装MySQL的步骤教程
-
windows系统下mysql数据库字符编码问题分析之需要修改字符集为UTF-8
-
linux下多个mysql5.7.19(tar.gz)安装图文教程
-
linux下mysql5.7.19(tar.gz)安装图文教程