随笔分类 -  mysql

摘要:-- 数据准备 create database taobao; use taobao; create table UserBehavior( user_id int, item_id int, item_category int, behavior_type varchar(10), user_ge 阅读全文
posted @ 2021-10-16 20:48 charlly 阅读(177) 评论(0) 推荐(0) 编辑
摘要:-- 数据准备 create database taobao; use taobao; create table UserBehavior( user_id int, item_id int, item_category int, behavior_type varchar(10), user_ge 阅读全文
posted @ 2021-10-16 11:03 charlly 阅读(407) 评论(0) 推荐(0) 编辑
摘要:truncate table orders;-- 删除表orders数据 #删除数据 # delete from 表名[ where 删除条件]; # truncate 表名;(与delete from 表名一样,都是删除表中全部数据,保留表结构) #delete和truncate的区别: #dle 阅读全文
posted @ 2021-10-10 11:52 charlly 阅读(79) 评论(0) 推荐(0) 编辑
摘要:create database meicaiwang; use meicaiwang; create table driver_daily( driver_id varchar(10), driver_name varchar(10), city_id varchar(10), city_name 阅读全文
posted @ 2021-10-06 23:30 charlly 阅读(42) 评论(0) 推荐(0) 编辑
摘要:create database markt; use markt; create table user_buy_all( uuid int, pay_tm datetime, product varchar(10), amount decimal, primary key(uuid,pay_tm) 阅读全文
posted @ 2021-10-06 23:04 charlly 阅读(27) 评论(0) 推荐(0) 编辑
摘要:use exercise; create table dic_area( id int(1), area_id int(6), area_name varchar(10), parented int(6), area_level int(1)); insert into dic_area value 阅读全文
posted @ 2021-10-06 22:57 charlly 阅读(152) 评论(0) 推荐(0) 编辑
摘要:create database exercise; use exercise; create table 揽收表( 运单号 char(7) primary key, 客户id char(5), 创建日期 date ); insert into 揽收表 values ('PNO0001','CC001 阅读全文
posted @ 2021-10-06 22:53 charlly 阅读(118) 评论(0) 推荐(0) 编辑
摘要:show variables like '%secure%';-- 查看安全路径,随后将表格粘贴到该安全路径下, load data infile "C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/dw_v_order_base.csv" -- shift 阅读全文
posted @ 2021-10-06 13:26 charlly 阅读(139) 评论(0) 推荐(0) 编辑
摘要:- 常用函数 -- 数学函数 -- 练习:查询各部门员工人数占比(保留两位小数) select deptno,count(*) as 部门人数, round(count(*)/(select count(*) from emp),2) as 人数占比 from emp group by deptno 阅读全文
posted @ 2021-10-06 13:13 charlly 阅读(78) 评论(0) 推荐(0) 编辑
摘要:create database CDA; use CDA; create table order_tab( order_id int, user_no varchar(3), amount int, create_date date ); insert into order_tab values ( 阅读全文
posted @ 2021-10-06 13:10 charlly 阅读(302) 评论(0) 推荐(0) 编辑
摘要:- 子查询 -- 标量子查询: -- 查询基本工资高于公司平均工资的员工信息 select * from emp where sal>(select avg(sal) from emp); -- 练习:查询和allen同一个领导的员工:empno,ename,job,mgr select empno 阅读全文
posted @ 2021-10-06 13:01 charlly 阅读(71) 评论(0) 推荐(0) 编辑
摘要:-- 多表连接查询 create table t1(key1 char,v1 int); create table t2(key2 char,v2 int); insert into t1 values('a',1),('a',2),('b',3),('c',4),('a',13); insert 阅读全文
posted @ 2021-10-06 13:00 charlly 阅读(101) 评论(0) 推荐(0) 编辑
摘要:-- 聚合运算 -- 查询emp表中员工总数、最高工资、最低工资、平均工资及工资总和 select count(*) as 员工总数, max(sal) as 最高工资, min(sal) as 最低工资, avg(sal) as 平均工资, sum(sal) as 工资总和 from emp; s 阅读全文
posted @ 2021-10-06 12:51 charlly 阅读(145) 评论(0) 推荐(0) 编辑
摘要:-- 继续mysql自我练习基础1, 数据和表格沿用基础1-- 单表查询(虚拟结果集) select * from emp; -- 检查表emp所有字段数据内容 -- 查询指定列:查询emp表中ename,job,sal select ename,job,sal from emp; -- 设置别名: 阅读全文
posted @ 2021-10-06 12:48 charlly 阅读(179) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示