资料仅供参考
group by tb.id having
num = select count(role)from tb where
id=xxx;
11、一个用户表中有一个积分字段,假如数据库中有 100 多万个用户,若要在 每年第一天凌晨将积分清零,你将考虑什么,你将想什么办法解决?
alter table drop column score;
资料仅供参考
alter table add colunm score int; 可能会很快,可是需要试验,试验不能拿真实的环境来操刀,而且要注意, 这样的操作时无法回滚的,在我的印象中,只有 inert update delete 等 DML 语句才能回滚, 对于 create table,drop table ,alter table 等 DDL 语句是不能回滚。
解决方案一,update user set score=0; 解决方案二,假设上面的代码要执行好长时间,超出我们的容忍范围,那我就 alter table user drop columnscore;alter table user add column score int。
下面代码实现每年的那个凌晨时刻进行清零。
Runnable runnable =
new Runnable(){
public voidrun(
){
clearDb();
schedule(this,newDate(new Date().getYear()+1,0,0));
资料仅供参考
}
};
schedule(runnable,
new Date(newDate().getYear()+1,0,1));
12、你对 Spring 的理解, 什么是 spring 的 IOC AOP。
1.Spring 实现了工厂模式的工厂类(在这里有必要解释清楚什么是工厂模式),这个类名为 BeanFactory(实际上是一个接口),在程序中一般 BeanFactory 的子类 ApplicationContext。 Spring 相当于一个大的工厂类,在其配置文件中经过
譬如,Class Programmer {
Computer computer =null; public void code() {
资料仅供参考
//Computercomputer = new IBMComputer();
//Computercomputer =
beanfacotry.getComputer(); computer.write(); }
public voidsetComputer(Computer computer)
资料仅供参考
{
this.computer= computer; }
} 另外两种方式都由依赖,第一个直接依赖于目标类,第二个把依赖转移到工厂上,第三个彻 底与目标和工厂解耦了。在 spring 的配置文件中配置片段如下:
class=”cn.itcast.interview.Computer”>
class=”cn.itcast.interview.Programmer”>
ref=”computer”>
3. Spring 提供了对 AOP 技术的良好封装, AOP 称为面向切面编程,就是系统中有很多各 不相干的类的方法,在这些众多方法中要加入某种系统功能的代码,例如,加入日志,加入 权限判断,加入异常处理,这种应用称为
相关推荐: