标签:load data esc load one 个数 类型 多选 varchar 信息
SELECT name,age,salary,phone FROM employee ORDER BY salary DESC;
SELECT MAX(salary) AS max_salary,MIN(salary) FROM employee;
想要知道名为 "Tom" 的员工所在部门做了几个工程。员工信息储存在 employee 表中,但工程信息储存在 project 表中。
对于这样的情况,我们可以用子查询:
SELECT of_dpt,COUNT(proj_name) AS count_project FROM project GROUP BY of_dpt
HAVING of_dpt IN
(SELECT in_dpt FROM employee WHERE name=‘Tom‘);
SELECT id,name,people_num
FROM employee JOIN department
ON employee.in_dpt = department.dpt_name
ORDER BY id;
#另一种等价写法
SELECT id,name,people_num
FROM employee,department
WHERE employee.in_dpt = department.dpt_name
ORDER BY id;
ALTER TABLE employee ADD INDEX idx_id (id); #在employee表的id列上建立名为idx_id的索引
CREATE INDEX idx_name ON employee (name); #在employee表的name列上建立名为idx_name的索引
#这里把视图当作一张表使用
CREATE VIEW v_emp (v_name,v_age,v_phone) AS SELECT name,age,phone FROM employee;
LOAD DATA INFILE ‘文件路径和文件名‘ INTO TABLE 表名字;
mysqldump -u root 数据库名>备份文件名; #备份整个数据库
mysqldump -u root 数据库名 表名字>备份文件名; #备份整个表
结合备份,把刚刚备份的数据恢复到数据库中
mysql -u root test < bak.sql
标签:load data esc load one 个数 类型 多选 varchar 信息
原文地址:https://www.cnblogs.com/irisiscool/p/12599873.html