【面試】資料庫相關
1.有如下資料,怎麼查詢顯示結果為 張三, 北京 河北, 12:00
nameaddressarrive_time 張三北京10:00 張三河北12:00 SELECT name, GROUP_CONCAT(DISTINCT address SEPARATOR ' ') AS address, max(arrive_time) AS arrive_time FROM mytable GROUP BY name;
2.如何查詢重複資料?
SELECT * FROM student GROUP BY name HAVING count(name ) > 1
3.查詢結果如何去重?
distinct關鍵字或者group by
4.Oracle資料庫分頁查詢
select a1.* from (select student.*,rownum rn from student where rownum <=5) a1 where rn >=3;
5.delete、truncate、drop都是刪除語句,他們的區別是什麼
在速度上,一般來說,drop> truncate > delete delete用於刪除部分資料 truncate 刪除整個表然後重新建立這個表(相當於清空了表資料) drop 摧毀整個表
6.資料庫主鍵和外來鍵作用
7.where和having的區別
8.union和union all的區別
9.資料庫事務正確執行的四個基本要素是什麼
10.有如下資料,查詢出每門課都大於80分的學生姓名
nameclassscore 蔡徐坤語文80 蔡徐坤英語55 吳亦凡語文100 吳亦凡英語90 鄧紫棋英語85 鄧紫棋數學70 鄧紫棋語文95 select name from table group by name having min(score)>80
11.資料庫優化策略