linux下mysql数据库编程练习_MySQL
程序员文章站
2022-05-01 08:48:04
...
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)
推荐阅读
-
Linux下通过python访问MySQL、Oracle、SQL Server数据库的方法
-
linux下改良版本mysqldump来备份MYSQL数据库
-
linux下mysql的安装步骤
-
《PHP编程最快明白》第六讲:Mysql数据库操作
-
Linux下远程连接MySQL数据库的方法
-
Linux下修改MySQL数据库数据文件路径的步骤
-
linux下mysql乱码问题的解决方案
-
IIS下PHP连接数据库提示mysql undefined function mysql_connect()
-
阿里云Linux CentOS 7.2下自建MySQL的root密码忘记的解决方法
-
Linux下MySQL 5.6.27 安装教程