面试题
汇总
- Java
- 双亲委派机制
- 代理模式
- 单例
- 面向接口编程
- 内存模型
- 线程池参数
- Abstract类和接口的区别
- HashMap put的过程
- HashMap 扩容的过程
- SQL
- 存储过程
- 索引一般是如何创建的
- 数据库隔离级别及其现象
- B树和B+树的区别
- MySQL安装和使用
- Spring
- Tradtional什么时候不生效
- 四个常用的配置注解
- Redis
- 数据类型
- 多路复用
- 缓存击穿
- 缓存雪崩
- 中间件
- 注册中心
SQL
存储过程
- 在数据库中存储复杂程序,以便外部程序调用的一种数据库对象
- 完成特定功能的SQL语句集,经编译创建并保存在数据库中,用户可通过指定存储过程的名字并给丁参数来执行。
- 存储过程没有返回值
- 创建
- 可以设置窗口的结尾符号
delemitor #create procedure 存储过程名(参数) begin sql end#create procedure pro_a() begin select * from users; select * from students; select * from classes; end#
- 带参数的存储过程
- 类型写后面
- 如果一个参数没有写类型,默认为in类型
- limit不能传值
- in
create procedure getStudentById(in x int) begin select * from students where id = x; end#```sql create procedure d(in class int, in name varchar(20)) begin select * from students where sclass = class or sname = name; end#
- out
- 执行out之前需要先定义变量
- 变量必须@符号开头
- `set @x = 1;`
- 显示变量值
- `select @x;`
- 调用
- `call pro_r1(@x)#`
```sql
create procedure pro_r1(out x int)
begin
select max(sscore) into x
from t_sutdent
where sclass = 3;
end#
create procedure r(in x int, out name varchar)
begin
select name from class where id = x;
end
- inout
create procedure r(inout x int) begin select max(score) into x where id = x; end; - 调用
call 存储过程名(实参)call pro_a() #- 无参数调用
call pro_b :
SQL 开窗函数
- Windows Functions
- 将没有聚集的列和聚集的列结合在一起
基本语法
- 计算累积总计工资
- partition by 分割
- order by
- rows between and
如何查询SQL数据库中有多少数据
- select count() from name
SQL select table_name,table_rows from information_schema.tables where table_schema = '数据库名' order by table_rows DECS
如何查看SQL执行计划
- 在SQL前加上explain关键词
- 可以看到是否使用索引,使用什么索引
接口和抽象类的区别
- 抽象类是一个类,而接口只是一个接口
- java 8 中接口也可以写默认和静态实现方法,但是不能写构造方法,但抽象类可以
- 抽象类可以有自己的各种成员变量,并且可以通过自己的非抽象方法进行改变,而接口中的变量都是public static final修饰的,意味着都是常量
- 接口可以实现多继承,而抽象类只能单继承