用户名密码登录
mysql -uroot -proot
执行SQL脚本
source 路劲
查看表结构
describe 缩写为 desc
mysql> describe emp;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| EMPNO | int(4) | NO | PRI | NULL | | 员工编号
| ENAME | varchar(10) | YES | | NULL | | 员工姓名
| JOB | varchar(9) | YES | | NULL | | 员工岗位
| MGR | int(4) | YES | | NULL | | 上级编号
| HIREDATE | date | YES | | NULL | | 入职日期
| SAL | double(7,2) | YES | | NULL | | 工资
| COMM | double(7,2) | YES | | NULL | | 补助
| DEPTNO | int(2) | YES | | NULL | | 部门编号
+----------+-------------+------+-----+---------+-------+
8 rows in set (0.00 sec)
mysql> desc salgrade;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| GRADE | int(11) | YES | | NULL | | 工资等级
| LOSAL | int(11) | YES | | NULL | | 最高工资
| HISAL | int(11) | YES | | NULL | | 最低工资
+-------+---------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> desc dept;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| DEPTNO | int(2) | NO | PRI | NULL | | 部门编号
| DNAME | varchar(14) | YES | | NULL | | 部门名字
| LOC | varchar(13) | YES | | NULL | | 部门位置
+--------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
查看数据库版本号
mysql> select version();
+------------+
| version() |
+------------+
| 5.7.31-log |
+------------+
1 row in set (0.00 sec)
查询当前使用的数据库
mysql> select database();
+-------------+
| database() |
+-------------+
| bjpowernode |
+-------------+
1 row in set (0.00 sec)
- 在命令行中不见分好