windows下的dos命令操作数据库
登录数据库mysql -u root -p
查看数据库列表show databases;
选择数据库并进入use [databases name];
查看数据库下的所有表show tables;
退出数据库exit;
SQL语句
略
常用函数
获取当前系统时间 SELECT NOW() as now_time;
查看当前数据库版本SELECT version();
统计行数SELECT COUNT(*) as rows FROM student_info;
求和SELECT SUM(s_age) FROM student_info;
求平均值SELECT AVG(s_age) FROM student_info;
求最大值SELECT MAX(s_age) FROM student_info;
求最小值SELECT MIN(s_age) FROM student_info;
四舍五入,约束小数点后几位SELECT ROUND(3.1415926, 5);
日期格式化SELECT DATE_FORMAT('2021/12/03 12:26:31', '%Y-%m-%d %H:%i:%s');
拼接字符串SELECT id, s_name, CONCAT(s_age, '岁') from student_info;
去除重复记录(单字段)SELECT DISTINCT s_age FROM student_info;
去除重复记录(多字段)SELECT DISTINCT s_name, s_age FROM student_info;