Rumah > pangkalan data > tutorial mysql > linux下mysql数据库编程练习_MySQL

linux下mysql数据库编程练习_MySQL

WBOY
Lepaskan: 2016-05-31 08:46:21
asal
1457 orang telah melayarinya

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)

sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan