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)
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | ZHANG | | company | | mysql | | performance_schema | | test | +--------------------+ 6 rows in set (0.00 sec) mysql> drop ZHANG -> ; 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 'ZHANG' at line 1 mysql> DROP DATABASE ZHANG; Query OK, 0 rows affected (0.03 sec) mysql> CREATE DATABASE linuxcast; Query OK, 1 row affected (0.00 sec) mysql> USE linuxcast; Database changed mysql> CREATE TABLE lC_course(id int, course_name varchar(100),course_length int(10),teacher varchar(50),caategory varchar(100)); Query OK, 0 rows affected (0.15 sec) mysql> mysql> mysql> show Tables; +---------------------+ | Tables_in_linuxcast | +---------------------+ | lC_course | +---------------------+ 1 row in set (0.00 sec) mysql> DESCRIBE lc_course; ERROR 1146 (42S02): Table 'linuxcast.lc_course' doesn't exist mysql> DESCRIBE lc_course; ERROR 1146 (42S02): Table 'linuxcast.lc_course' doesn't exist mysql> DESCRIBE lC_course; +---------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+--------------+------+-----+---------+-------+ | id | int(11) | YES | | NULL | | | course_name | varchar(100) | YES | | NULL | | | course_length | int(10) | YES | | NULL | | | teacher | varchar(50) | YES | | NULL | | | caategory | varchar(100) | YES | | NULL | | +---------------+--------------+------+-----+---------+-------+ 5 rows in set (0.10 sec) mysql> DESC lC_course; +---------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+--------------+------+-----+---------+-------+ | id | int(11) | YES | | NULL | | | course_name | varchar(100) | YES | | NULL | | | course_length | int(10) | YES | | NULL | | | teacher | varchar(50) | YES | | NULL | | | caategory | varchar(100) | YES | | NULL | | +---------------+--------------+------+-----+---------+-------+ 5 rows in set (0.00 sec) mysql> show tables; +---------------------+ | Tables_in_linuxcast | +---------------------+ | lC_course | +---------------------+ 1 row in set (0.00 sec) mysql> ALTER TABLE lC_course REMALE course; 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 'REMALE course' at line 1 mysql> ALTER TABLE lC_course RENAME course; Query OK, 0 rows affected (0.16 sec) mysql> show tabels; 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 'tabels' at line 1 mysql> show tables; +---------------------+ | Tables_in_linuxcast | +---------------------+ | course | +---------------------+ 1 row in set (0.00 sec) mysql> decs course; 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 'decs course' at line 1 mysql> DESC course; +---------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+--------------+------+-----+---------+-------+ | id | int(11) | YES | | NULL | | | course_name | varchar(100) | YES | | NULL | | | course_length | int(10) | YES | | NULL | | | teacher | varchar(50) | YES | | NULL | | | caategory | varchar(100) | YES | | NULL | | +---------------+--------------+------+-----+---------+-------+ 5 rows in set (0.03 sec) mysql> ALTER TABLE course ADD link varchar(200); Query OK, 0 rows affected (0.28 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> DESC course; +---------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+--------------+------+-----+---------+-------+ | id | int(11) | YES | | NULL | | | course_name | varchar(100) | YES | | NULL | | | course_length | int(10) | YES | | NULL | | | teacher | varchar(50) | YES | | NULL | | | caategory | varchar(100) | YES | | NULL | | | link | varchar(200) | YES | | NULL | | +---------------+--------------+------+-----+---------+-------+ 6 rows in set (0.00 sec) mysql> ALTER TABLE course DROP COLUMN link; Query OK, 0 rows affected (0.10 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> DESC course; +---------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+--------------+------+-----+---------+-------+ | id | int(11) | YES | | NULL | | | course_name | varchar(100) | YES | | NULL | | | course_length | int(10) | YES | | NULL | | | teacher | varchar(50) | YES | | NULL | | | caategory | varchar(100) | YES | | NULL | | +---------------+--------------+------+-----+---------+-------+ 5 rows in set (0.01 sec) mysql> mysql> ALTER TABLE course MODIFY teacher varchar(100); Query OK, 0 rows affected (0.09 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> ALTER TABLE course CHANGE COLUMN caategory tategory varchar(100); Query OK, 0 rows affected (0.10 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> DESC course -> ; +---------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+--------------+------+-----+---------+-------+ | id | int(11) | YES | | NULL | | | course_name | varchar(100) | YES | | NULL | | | course_length | int(10) | YES | | NULL | | | teacher | varchar(100) | YES | | NULL | | | tategory | varchar(100) | YES | | NULL | | +---------------+--------------+------+-----+---------+-------+ 5 rows in set (0.00 sec)