赞
踩
# 在命令行下执行
> mysqldump -u root -p az > d:\data.sql;
create database 数据库名;
create database 数据库名;
// 用 show databases;看看有哪些数据库 show databases; // 结果 +--------------------+ | Database | +--------------------+ | information_schema | | kkk | | mysql | | performance_schema | | sys | +--------------------+ // 然后use即可 use kkk // 可以导入了 mysql> source D:\Mysql_data\test_data\test1\bjpowernode.sql // 查看导入的这张表的信息 show tables; +---------------+ | Tables_in_kkk | +---------------+ | dept | | emp | | salgrade | +---------------+ 3 rows in set (0.01 sec)
select * from 表名 mysql> select * from emp; +-------+--------+-----------+------+------------+---------+---------+--------+ | EMPNO | ENAME | JOB | MGR | HIREDATE | SAL | COMM | DEPTNO | +-------+--------+-----------+------+------------+---------+---------+--------+ | 7369 | SMITH | CLERK | 7902 | 1980-12-17 | 800.00 | NULL | 20 | | 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30 | | 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30 | | 7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975.00 | NULL | 20 | | 7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30 | | 7698 | BLAKE | MANAGER | 7839 | 1981-05-01 | 2850.00 | NULL | 30 | | 7782 | CLARK | MANAGER | 7839 | 1981-06-09 | 2450.00 | NULL | 10 | | 7788 | SCOTT | ANALYST | 7566 | 1987-04-19 | 3000.00 | NULL | 20 | | 7839 | KING | PRESIDENT | NULL | 1981-11-17 | 5000.00 | NULL | 10 | | 7844 | TURNER | SALESMAN | 7698 | 1981-09-08 | 1500.00 | 0.00 | 30 | | 7876 | ADAMS | CLERK | 7788 | 1987-05-23 | 1100.00 | NULL | 20 | | 7900 | JAMES | CLERK | 7698 | 1981-12-03 | 950.00 | NULL | 30 | | 7902 | FORD | ANALYST | 7566 | 1981-12-03 | 3000.00 | NULL | 20 | | 7934 | MILLER | CLERK | 7782 | 1982-01-23 | 1300.00 | NULL | 10 | +-------+--------+-----------+------+------------+---------+---------+--------+
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 | | // 地理位置 +--------+-------------+------+-----+---------+-------+ desc 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 | | // 部门编号 +----------+-------------+------+-----+---------+-------+ mysql> desc salgrade; +-------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+---------+------+-----+---------+-------+ | GRADE | int(11) | YES | | NULL | | // 工资等级 | LOSAL | int(11) | YES | | NULL | | // 最低工资 | HISAL | int(11) | YES | | NULL | | // 最高工资 +-------+---------+------+-----+---------+-------+
// 查看版本号 1. mysql> select version(); +------------+ | version() | +------------+ | 5.7.42-log | +------------+ // 查看当前使用的是哪个数据库 2. mysql> select database(); +------------+ | database() | +------------+ | kkk | +------------+ 3. MySQL是不见分号不执行 写一半不想写了怎么办:\c(用来终止一条sql语句的输出入) mysql> show -> databases -> ; +--------------------+ | Database | +--------------------+ | information_schema | | kkk | | mysql | | performance_schema | | sqlfile | | sys | +--------------------+
1. mysql> select DNAME,LOC as dd from dept; +------------+----------+ | DNAME | dd | +------------+----------+ | ACCOUNTING | NEW YORK | | RESEARCH | DALLAS | | SALES | CHICAGO | | OPERATIONS | BOSTON | +------------+----------+ 也可以把“as”省略 select DNAME,LOC dd from dept; // 如果起的别名里有空格,用单引号(双引号也行)括起来 2. mysql> select DNAME,LOC 'd d' from dept; +------------+----------+ | DNAME | d d | +------------+----------+ | ACCOUNTING | NEW YORK | | RESEARCH | DALLAS | | SALES | CHICAGO | | OPERATIONS | BOSTON | +------------+----------+ **3. 表达式** mysql> select ename,sal*12 as 'double' from emp -> ; +--------+----------+ | ename | double | +--------+----------+ | SMITH | 9600.00 | | ALLEN | 19200.00 | | WARD | 15000.00 | | JONES | 35700.00 | | MARTIN | 15000.00 | | BLAKE | 34200.00 | | CLARK | 29400.00 | | SCOTT | 36000.00 | | KING | 60000.00 | | TURNER | 18000.00 | | ADAMS | 13200.00 | | JAMES | 11400.00 | | FORD | 36000.00 | | MILLER | 15600.00 | +--------+----------+
都有哪些条件啊?
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。