mysql 命令
1.查看数据库:
mysql> show databases;
2.使用数据库
mysql> use mysqldata;
3.查看数据表
mysql> show tables;
4.新建数据表:
mysql> create table mytable (name varchar(20),sex char(1));
Query OK, 0 rows affected (0.45 sec)
5.查看表结构:
mysql> describe mytable;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| name | varchar(20) | YES | | NULL | |
| sex | char(1) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.08 sec)
6.表添加数据:
mysql> insert into mytable values('zhanglixia','M');
Query OK, 1 row affected (0.10 sec)
7.删除数据库:
mysql> drop table mytable;
8.更改表数据:
mysql> update mytable set sex='f' where name ='zhanglixia';
Query OK, 1 row affected (0.07 sec)
9.清空表数据:
mysql> delete from mytable;
Query OK, 1 row affected (0.07 sec)