免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5947 | 回复: 8
打印 上一主题 下一主题

数据库面试题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-03-17 16:41 |只看该作者 |倒序浏览
面试题(汇总所有的数据库面试题).rar (844.55 KB, 下载次数: 3397)

附带很多个公司的数据库面试题目 绝对经典

论坛徽章:
0
2 [报告]
发表于 2011-03-24 15:34 |只看该作者
你太给力了 谢谢……

论坛徽章:
0
3 [报告]
发表于 2011-08-03 18:41 |只看该作者
1. Which will be faster out of these two queries – one with OR or one with IN?
   2. Where does MyISAM cache table records?
   3. Which will be faster out of queries with explicit INNER JOIN and implicit one?
   4. Is InnoDB faster/better than MyISAM?
   5. Is CHAR faster than VARCHAR?
   6. Is VARCHAR(80) faster than VARCHAR(255)?
   7. Are there performance issues when joining tables from different storage engines?
   8. If I change a derived table to a view, will performance increase?
   9. If I see Using temporary; Using filesort” in the Extra column of EXPLAIN output, does that mean a temporary table is created on disk?
  10. Is it possible to do a FULL OUTER JOIN in MySQL?

论坛徽章:
0
4 [报告]
发表于 2011-08-03 20:51 |只看该作者
mysql derived table and view the performance

February 25th, 2007 admin Posted in SQL SERVER |

  Starting MySQL 4.1, MySQL had support for what is called derived tables, inline views or basically subselects in the from clause.

  In MySQL 5.0 support for views was added.

  MySQL 4.1 from the beginning, it has derived support table, or on-line view of the basic FROM clause of the query.

  These features are quite related to each other but how do they compare in terms of performance?

  These features are related to each other between, but the performance comparison between them how to do »

  Derived Tables in MySQL 5.0 seems to have different implementation from views, even though I would expect code base to be merged as it is quite the same task in terms of query optimization.

  MySQL 5.0 in the table seems to be derived and the ways to achieve different view, although I understand from the merger of the code base that view on the query optimization should be the same.

  Derived Tables are still handled by materializing them in the temporary table, furthermore temporary table with no indexes (so you really do not want to join two derived tables for example).

  Derived temporary table to table are still the way to deal with explicit, but are not indexed temporary table (and therefore best not to like, as in the case of connecting two derived table).

  One more thing to watch for is the fact derived table is going to be materialized even to execute EXPLAIN statement. So if you have done mistake in select in from clause, ie forgotten join condition you might have EXPLAIN running forever.

  On the other hand the need to consider is that the derivative forms of treatment needs to be significant, although only the implementation of EXPLAIN statement.    So if everything in FROM in SELELCT operational mistakes, for example, have forgotten to write on the link conditions, then EXPLAIN may have been in operation.

  Views on other hand do not have to be materialized and normally executed by rewriting the query. It only will be materialized if query merge is impossible or if requested by view creator.

  View is different, it need not be explicit with only a simple query to rewrite the click.    Not only in trying to create a joint enquiries or when the request needs to be explicit treatment.

  What does it mean in terms of performance:

  This means that they are the differences in performance are as follows:

  PLAIN TEXT

SQL:

  Query ON base TABLE executes USING INDEX AND it IS very fast

  In the basic form for the implementation of the index, which very quickly

  MySQL> SELECT * FROM test WHERE i = 5;
+—+———————————-+
  | I | j |
+—+———————————-+
  | 5 | 0c88dedb358cd96c9069b73a57682a45 |
+—+———————————-+
  1 row IN SET (0.03 sec)

  Same query USING derived TABLE crawls:

  In derivatives on the table do the same query, such as car break Laoniu Rafah

  mysql> SELECT * FROM (SELECT * FROM test) t WHERE i = 5;
  +---+----------------------------------+
  | I | j |
  +---+----------------------------------+
  | 5 | 0c88dedb358cd96c9069b73a57682a45 |
  +---+----------------------------------+
  1 row IN SET (1 min 40.86 sec)
  Query USING VIEW IS fast again:

  In an attempt to query on, fast and up

  mysql> CREATE VIEW v AS SELECT * FROM test;
  Query OK, 0 rows affected (0.08 sec)
  mysql> SELECT * FROM v WHERE i = 5;
  +---+----------------------------------+
  | I | j |
  +---+----------------------------------+
  | 5 | 0c88dedb358cd96c9069b73a57682a45 |
  +---+----------------------------------+
  1 row IN SET (0.10 sec)
  Here are couple of explains IF you are curios

  Below the two EXPLAIN results may allow you are very surprised

  mysql> EXPLAIN SELECT * FROM v WHERE i = 5;
  +----+-------------+-------+-------+-------------- -+---------+---------+-------+------+-------+
  | Id | select_type | TABLE | type | possible_keys | KEY | key_len | ref | rows | Extra |
  +----+-------------+-------+-------+-------------- -+---------+---------+-------+------+-------+
  | 1 | PRIMARY | test | const | PRIMARY | PRIMARY | 4 | const | 1 | |
  +----+-------------+-------+-------+-------------- -+---------+---------+-------+------+-------+
  1 row IN SET (0.02 sec)
  mysql> EXPLAIN SELECT * FROM (SELECT * FROM test) t WHERE i = 5;
  +----+-------------+------------+------+---------- -----+------+---------+------+---------+---------- --- +
  | Id | select_type | TABLE | type | possible_keys | KEY | key_len | ref | rows | Extra |
  +----+-------------+------------+------+---------- -----+------+---------+------+---------+---------- --- +
  | 1 | PRIMARY | <derived2> | ALL | NULL | NULL | NULL | NULL | 1638400 | USING WHERE |
  | 2 | DERIVED | test | ALL | NULL | NULL | NULL | NULL | 1638400 | |
  +----+-------------+------------+------+---------- -----+------+---------+------+---------+---------- --- +
  2 rows IN SET (54.90 sec)

  Note how long it took just TO execute EXPLAIN FOR derived TABLE

  Please note that after many spent a long time before the implementation of End EXPLAIN.

  So what does it mean in practice:

  In practice, this means that:

  Avoid derived tables - If there is other way to write the query it will be faster in most cases. In many cases even separate temporary table will be faster as you can add proper indexes to the table in this case.

  Avoid the use of derivatives table - if possible, preferably using other means to prepare query, the majority of cases than those derived from the table to fast.    In many cases, even independent of the temporary table to have the fast, because they can increase the appropriate index.

  Consider using temporary views instead of derived tables If you really need to use subselect in from clause consider creating view using it in the query and dropping it after query was executed.

  May consider trying to replace the temporary use of derivatives in Table If you do need to use in the FROM clause of enquiries, enquiries can be considered in an attempt to create, when trying to delete End enquiries.

  In any case it is pretty annoying gotcha which I hope MySQL will fix in next MySQL versions - the fact queries in this example behave differently is illogical and counter intuitive.

  In any case, this is very annoying, I hope MYSQL to the next version of its solution - in this example for the performance is so different in fact the only illogical roughly estimates.  

http://www.dd64.com/mysql-derived-table-and-view-the-performance/

论坛徽章:
0
5 [报告]
发表于 2011-08-09 10:39 |只看该作者
谢谢楼主的分享

论坛徽章:
0
6 [报告]
发表于 2011-08-11 15:47 |只看该作者
好贴

论坛徽章:
0
7 [报告]
发表于 2011-08-19 09:53 |只看该作者
面试一样,我带了个小本,提前半个小时到达了H3C楼下,远远地看见中央H3C,ITOIP几个大字。甚感亲切,让我亲切的不是H3C,而是ITOIP。我给HR打了个电话,然后HR就下来接我了。HR带我来到了一个工作间,不知道为什么,里面没什么人,很多位置都空着。四周打探了一下,发现这里跟其他公司不一样最突出的地方就是桌子底下多了很多铺盖卷,大概我已经知道了这是意味着什么。不久HR拿来一套面试题。以前跟朋友们一起聊天的时候,朋友们说他们都是每次都是一看到HR拿来面试题都是摔门就走,都"工作这么几年了,你还拿那些什么概念,什么函数来考我!”。我想大家都不愿意做面试题,其实我是不认同这个观点的。一个公司更希望招到有经验基础知识扎实的人,简历其实并不能说明一切,当然这是题外话了。预料之中,全是C语言,前面几道是选择题,后面是编程题目,指针链表当然少不了。我花了40分钟做完了技术部分,最后一部分是逻辑思维题目,都是什么图形,什么过河之类的题目。我做了一个就交了。对于程序设计题目,我并没有全部写完,很多步骤都是省略了,一句话带过。比如说很明显这道题目是考链表,涉及到排序的步骤我一句话:可用归并。。等等。

    交了答题纸,等了5分钟。一面的面试官来了。面试官带了个眼镜儿,很瘦但很干练,对着我的答案看了一会儿。一句话没说就扔在了一边。让我自我介绍。跟以往面试一样,我介绍了下我的经历,简单的介绍了我的几个项目。一面很短暂,大概10分钟的样子,因为这个工作间很大,人很少,我几乎就能听见我说话的回音。所以我反而有点不自然了。但是还好,我并没有表现出来。二面是个女士,过去之后,她问我为什么辞职,擅长什么。我说对于辞职的原因,很简单,我为我一直以来的梦想而来。我想踏踏实实做我想做的事情,我不喜欢安逸的环境。对于开发来说,我擅长搭建框架和API的设计。面试官接过话说:男就是没怎么写过程序咯?我说,没有啊,搭建框架并不代表我不写程序,恰恰相反,搭建框架不仅仅需要你对程序有很好的控制能力,而且需要你对业务的熟练掌握。。。正果过程都围绕着我写了多少代码,一边都怎么写代码等等展开的。二面很顺利的就过了。三面,同样是个女士,一上来,这个为面试官很明白的告诉我将来的薪水,我也跟他交了底,我说这个薪水我可以接受,我来这里更多的是创造价值的同时学习东西。说道这里,我的三面也就过了。呵呵,没想到还有四面。四面是个技术主管。他看了看我的简历然后说,你这个学校的人,至少我到这里来了之后都没见有招过。按照常规来说,H3C包括其他的大公司是不会招的。但是你的经历很丰富,就另当别论了。四面的主管给我的感觉就是很实在,精炼。所以,我也没谈太多,问起我的经历我也就是一句话带过。谈的最多的是我理想以及我对我自己的自我评价。差不多到6点的时候,面试结束了。也不轻松,感觉他们对于学历和学校有点选择。其实对于我来说我也很理解这种行为。因为公司买办法在那么一个小时内去深入的了解你的水平和能力,众多的应聘者也不能一眼看出来谁好谁坏。起码可以通过学校这道门槛首先刷掉一部分人。再从中筛选。但是学校也不是全部。技术和实力才是你最终的也是最重要的砝码。

http://blog.csdn.net/feiyinzilgd/article/details/6696283

论坛徽章:
59
2015七夕节徽章
日期:2015-08-24 11:17:25ChinaUnix专家徽章
日期:2015-07-20 09:19:30每周论坛发贴之星
日期:2015-07-20 09:19:42ChinaUnix元老
日期:2015-07-20 11:04:38荣誉版主
日期:2015-07-20 11:05:19巳蛇
日期:2015-07-20 11:05:26CU十二周年纪念徽章
日期:2015-07-20 11:05:27IT运维版块每日发帖之星
日期:2015-07-20 11:05:34操作系统版块每日发帖之星
日期:2015-07-20 11:05:36程序设计版块每日发帖之星
日期:2015-07-20 11:05:40数据库技术版块每日发帖之星
日期:2015-07-20 11:05:432015年辞旧岁徽章
日期:2015-07-20 11:05:44
8 [报告]
发表于 2011-08-21 20:49 |只看该作者
哪个公司的面试题啊。

论坛徽章:
0
9 [报告]
发表于 2012-11-05 16:22 |只看该作者
谢了,我会去看一看,里面到底有那些东西。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP