摘要:
函数参数分类,如下: 位置参数 默认参数 可变参数 关键字参数 组合参数 位置参数:x、n 为位置参数 def power(x, n): s = 1 while n > 0: n = n - 1 s = s * x return s 默认参数:n为默认参数,调用时,默认参数可以不用传 默认参数,可以 阅读全文
摘要:
Mysql总是通过创建和填充临时表的方式来执行union查询,导致很多优化策略不能在union中采取。 除非确实需要服务器消除重复的行,否则就一定要使用 union all。如果没有 all 关键字,mysql会给临时表加上distinct 选项, 这会导致对整个临时表的数据做唯一性检查。即使有Al 阅读全文
摘要:
group by with rollup,在group by 之上在进行一次汇总 mysql> select coalesce(staff_id,'汇总'), sum(amount) from payment group by staff_id with rollup; + + + | coales 阅读全文
摘要:
mysql> explain -> (select first_name,last_name from sakila.actor order by last_name) -> union all -> (select first_name,last_name from sakila.customer 阅读全文
摘要:
-- 如下两种写法等效,一般,通过 exists 的写法更高效mysql> explain select * from sakila.film where film_id in (select film_id from sakila.film_actor where actor_id = 1); + 阅读全文