
<p> 【IT168 评论】在今年上半年的数据库使用状况调查中,笔者收集了众多国内外知名互联网公司的数据库使用情况,其中,国外GitHub、Airbnb、Yelp、Coursera均在使用MySQL数据库,国内阿里巴巴、去哪儿网、腾讯、魅族、京东的部分关键业务同样使用了MySQL数据库。同时,MySQL也是众多数据库排行榜单的第一名,这个开发者和一线互联网企业都在用的开源数据库,你了解多少?这份MySQL自测卷,你会多少呢?</p><p style="text-align:center;"><img src="http://image20.it168.com/_0x0/3071/d71210e1bd4b9fae.jpg" border="1" alt="MySQL面试题,据说知名互联网公司都用"/><br/></p><p> <strong>1、一张表,里面有ID自增主键,当insert了17条记录之后,删除了第15,16,17条记录,再把Mysql重启,再insert一条记录,这条记录的ID是18还是15 ?</strong></p><p style="text-align:center;"><img src="http://image20.it168.com/_670x502/3071/e66570c87d4739e1.jpg" border="1" alt="MySQL面试题,据说知名互联网公司都用"/><br/></p><p> <strong> 2、MySQL的技术特点是什么?</strong><br/></p><p> MySQL数据库软件是一个客户端或服务器系统,其中包括:支持各种客户端程序和库的多线程SQL服务器、不同的后端、广泛的应用程序编程接口和管理工具。</p><p> <strong>3、Heap表是什么?</strong></p><p> <span style="font-size: 16px;"> <strong>·</strong></span>HEAP表存在于内存中,用于临时高速存储。</p><p> <strong><span style="font-size: 16px;">·</span></strong>BLOB或TEXT字段是不允许的</p><p> <strong><span style="font-size: 16px;">·</span></strong>只能使用比较运算符=,<,>,=>,= <</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>HEAP表不支持AUTO_INCREMENT</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>索引不可为NULL</p><p><strong> 4、MySQL服务器默认端口是什么?</strong></p><p> MySQL服务器的默认端口是3306。</p><p><strong> 5、与Oracle相比,MySQL有什么优势?</strong></p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>MySQL是开源软件,随时可用,无需付费。</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>MySQL是便携式的</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>带有命令提示符的GUI。</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>使用MySQL查询浏览器支持管理</p><p> <strong>6、如何区分FLOAT和DOUBLE?</strong></p><p> 以下是FLOAT和DOUBLE的区别:</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>浮点数以8位精度存储在FLOAT中,并且有四个字节。</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>浮点数存储在DOUBLE中,精度为18位,有八个字节。</p><p> <strong>7、区分CHAR_LENGTH和LENGTH?</strong></p><p> CHAR_LENGTH是字符数,而LENGTH是字节数。Latin字符的这两个数据是相同的,但是对于Unicode和其他编码,它们是不同的。</p><p> <strong> 8、请简洁描述MySQL中InnoDB支持的四种事务隔离级别名称,以及逐级之间的区别?</strong></p><p> SQL标准定义的四个隔离级别为:</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>read uncommited :读到未提交数据</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>read committed:脏读,不可重复读</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>repeatable read:可重读</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>serializable :串行事物</p><p><img src="http://p3.pstatp.com/large/46e10003c7d0d30a5710" alt="MySQL面试题集锦,据说国内外知名互联网公司都在用!" width="640" height="233" align=""/></p><p><img src="http://p1.pstatp.com/large/46ecc3b31cc" alt="MySQL面试题集锦,据说国内外知名互联网公司都在用!" width="640" height="255" align=""/></p><p> <strong>9、在MySQL中ENUM的用法是什么?</strong></p><p> ENUM是一个字符串对象,用于指定一组预定义的值,并可在创建表时使用。</p><p> Create table size(name ENUM('Smail,'Medium','Large');</p><p> <strong> 10、如何定义REGEXP?</strong></p><p> REGEXP是模式匹配,其中匹配模式在搜索值的任何位置。</p><p> <strong> 11、CHAR和VARCHAR的区别?</strong></p><p> 以下是CHAR和VARCHAR的区别:</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>CHAR和VARCHAR类型在存储和检索方面有所不同</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>CHAR列长度固定为创建表时声明的长度,长度值范围是1到255</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>当CHAR值被存储时,它们被用空格填充到特定长度,检索CHAR值时需删除尾随空格。</p><p> <strong> 12、列的字符串类型可以是什么?</strong></p><p> 字符串类型是:</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>SET</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>BLOB</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>ENUM</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>CHAR</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>TEXT</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>VARCHAR</p><p><strong> 13、如何获取当前的MySQL版本?</strong></p><p> SELECT VERSION();用于获取当前MySQL的版本。</p><p><strong> </strong><strong>14、MySQL中使用什么存储引擎?</strong></p><p> 存储引擎称为表类型,数据使用各种技术存储在文件中。</p><p> 技术涉及:</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>Storage mechanism</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>Locking levels</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>Indexing</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>Capabilities and functions.</p><p> <strong>15、MySQL驱动程序是什么?</strong></p><p> 以下是MySQL中可用的驱动程序:</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>PHP驱动程序</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>JDBC驱动程序</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>ODBC驱动程序</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>CWRAPPER</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>PYTHON驱动程序</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>PERL驱动程序</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>RUBY驱动程序</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>CAP11PHP驱动程序</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>Ado.net5.mxj</p><p> <strong>16、TIMESTAMP在UPDATE CURRENT_TIMESTAMP数据类型上做什么?</strong></p><p> 创建表时TIMESTAMP列用Zero更新。只要表中的其他字段发生更改,UPDATE CURRENT_TIMESTAMP修饰符就将时间戳字段更新为当前时间。</p><p> <strong> 17、主键和候选键有什么区别?</strong></p><p> 表格的每一行都由主键唯一标识,一个表只有一个主键。</p><p> 主键也是候选键。按照惯例,候选键可以被指定为主键,并且可以用于任何外键引用。</p><p> <strong>18、如何使用Unix shell登录MySql?</strong></p><p> 我们可以通过以下命令登录:</p><p> # [mysql dir]/bin/mysql -h hostname -u <UserName> -p <password></p><p> <strong> 19、 myisamchk是用来做什么的?</strong></p><p> 它用来压缩MyISAM表,这减少了磁盘或内存使用。</p><p> <strong>20、MYSQL数据库服务器性能分析的方法命令有哪些?</strong></p><p><img src="http://p3.pstatp.com/large/46dd0004399f60a42185" alt="MySQL面试题集锦,据说国内外知名互联网公司都在用!" width="479" height="395" align=""/></p><p> <strong>21、如何控制HEAP表的最大尺寸?</strong></p><p> Heal表的大小可通过称为max_heap_table_size的MySQL配置变量来控制。</p><p> <strong> 22、MyISAM Static和MyISAM Dynamic有什么区别?</strong></p><p> 在MyISAM Static上的所有字段有固定宽度。动态MyISAM表将具有像TEXT,BLOB等字段,以适应不同长度的数据类型。</p><p> MyISAM Static在受损情况下更容易恢复。</p><p> <strong>23、federated表是什么?</strong></p><p> federated表,允许访问位于其他服务器数据库上的表。</p><p><strong> 24、如果一个表有一列定义为TIMESTAMP,将发生什么?</strong></p><p> 每当行被更改时,时间戳字段将获取当前时间戳。</p><p> <strong>25、列设置为AUTO INCREMENT时,如果在表中达到最大值,会发生什么情况?</strong></p><p> 它会停止递增,任何进一步的插入都将产生错误,因为密钥已被使用。</p><p> <strong>26、怎样才能找出最后一次插入时分配了哪个自动增量?</strong></p><p> LAST_INSERT_ID将返回由Auto_increment分配的最后一个值,并且不需要指定表名称。</p><p> <strong> 27、你怎么看到为表格定义的所有索引?</strong></p><p> 索引是通过以下方式为表格定义的:</p><p> SHOW INDEX FROM <tablename>;</p><p> <strong> 28.、LIKE声明中的%和_是什么意思?</strong></p><p> %对应于0个或更多字符,_只是LIKE语句中的一个字符。</p><p> <strong> 29、如何在Unix和MySQL时间戳之间进行转换?</strong></p><p> UNIX_TIMESTAMP是从MySQL时间戳转换为Unix时间戳的命令</p><p> FROM_UNIXTIME是从Unix时间戳转换为MySQL时间戳的命令</p><p> <strong>30、列对比运算符是什么?</strong></p><p> 在SELECT语句的列比较中使用=,<>,<=,<,> =,>,<<,>>,<=>,AND,OR或LIKE运算符。</p><p> <strong>31、我们如何得到受查询影响的行数?</strong></p><p> 行数可以通过以下代码获得:</p><p> SELECT COUNT(user_id)FROM users;</p><p> <strong>32、Mysql查询是否区分大小写?</strong></p><p> 不区分</p><p> SELECT VERSION(), CURRENT_DATE;</p><p> SeLect version(), current_date;</p><p> seleCt vErSiOn(), current_DATE;</p><p> 所有这些例子都是一样的,MySQL不区分大小写。</p><p> <strong>33.、LIKE和REGEXP操作有什么区别?</strong></p><p> LIKE和REGEXP运算符用于表示^和%。</p><p> SELECT * FROM employee WHERE emp_name REGEXP "^b";</p><p> SELECT * FROM employee WHERE emp_name LIKE "%b";</p><p><strong> 34.、BLOB和TEXT有什么区别?</strong></p><p> BLOB是一个二进制对象,可以容纳可变数量的数据。有四种类型的BLOB -</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>TINYBLOB</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>BLOB</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>MEDIUMBLOB和</p><p> <span style="font-size: 16px;"><b> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong></b></span>LONGBLOB</p><p> 它们只能在所能容纳价值的最大长度上有所不同。</p><p> TEXT是一个不区分大小写的BLOB。四种TEXT类型</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>TINYTEXT</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>TEXT</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>MEDIUMTEXT和</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>LONGTEXT</p><p> 它们对应于四种BLOB类型,并具有相同的最大长度和存储要求。</p><p> BLOB和TEXT类型之间的唯一区别在于对BLOB值进行排序和比较时区分大小写,对TEXT值不区分大小写。</p><p> <strong>35、mysql_fetch_array和mysql_fetch_object的区别是什么?</strong></p><p> 以下是mysql_fetch_array和mysql_fetch_object的区别:</p><p> mysql_fetch_array() - 将结果行作为关联数组或来自数据库的常规数组返回。</p><p> mysql_fetch_object - 从数据库返回结果行作为对象。</p><p> <strong>36、我们如何在mysql中运行批处理模式?</strong></p><p> 以下命令用于在批处理模式下运行:</p><p> mysql;</p><p> mysql mysql.out</p><p> <strong>37、MyISAM表格将在哪里存储,并且还提供其存储格式?</strong></p><p> 每个MyISAM表格以三种格式存储在磁盘上:</p><p> ·“.frm”文件存储表定义</p><p> ·数据文件具有“.MYD”(MYData)扩展名</p><p> 索引文件具有“.MYI”(MYIndex)扩展名</p><p> <strong> 38.、MySQL中有哪些不同的表格?</strong></p><p> 共有5种类型的表格:</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>MyISAM</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>Heap</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>Merge</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>INNODB</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>ISAM</p><p> MyISAM是MySQL的默认存储引擎。</p><p> <strong> 39、ISAM是什么?</strong></p><p> ISAM简称为索引顺序访问方法。它是由IBM开发的,用于在磁带等辅助存储系统上存储和检索数据。</p><p> <strong> 40、InnoDB是什么?</strong></p><p> lnnoDB是一个由Oracle公司开发的Innobase Oy事务安全存储引擎。</p><p> <strong> 41、MySQL如何优化DISTINCT?</strong></p><p> DISTINCT在所有列上转换为GROUP BY,并与ORDER BY子句结合使用。</p><p> 1</p><p> SELECT DISTINCT t1.a FROM t1,t2 where t1.a=t2.a;</p><p> <strong> 42、如何输入字符为十六进制数字?</strong></p><p> 如果想输入字符为十六进制数字,可以输入带有单引号的十六进制数字和前缀(X),或者只用(Ox)前缀输入十六进制数字。</p><p> 如果表达式上下文是字符串,则十六进制数字串将自动转换为字符串。</p><p> <strong>43、如何显示前50行?</strong></p><p> 在MySql中,使用以下代码查询显示前50行:</p><p> SELECT*FROM</p><p> LIMIT 0,50;</p><p> <strong>44、可以使用多少列创建索引?</strong></p><p> 任何标准表最多可以创建16个索引列。</p><p> <strong>45、NOW()和CURRENT_DATE()有什么区别?</strong></p><p> NOW()命令用于显示当前年份,月份,日期,小时,分钟和秒。</p><p> CURRENT_DATE()仅显示当前年份,月份和日期。</p><p> <strong> 46、什么样的对象可以使用CREATE语句创建?</strong></p><p> 以下对象是使用CREATE语句创建的:</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>DATABASE</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>EVENT</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>FUNCTION</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>INDEX</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>PROCEDURE</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>TABLE</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>TRIGGER</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>USER</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>VIEW</p><p> <strong>47.、MySql表中允许有多少个TRIGGERS?</strong></p><p> 在MySql表中允许有六个触发器,如下:</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>BEFORE INSERT</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>AFTER INSERT</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>BEFORE UPDATE</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>AFTER UPDATE</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>BEFORE DELETE and</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>AFTER DELETE</p><p> <strong>48、什么是非标准字符串类型?</strong></p><p> 以下是非标准字符串类型:</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>TINYTEXT</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>TEXT</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>MEDIUMTEXT</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>LONGTEXT</p><p> <strong> 49、什么是通用SQL函数?</strong></p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>CONCAT(A, B) - 连接两个字符串值以创建单个字符串输出。通常用于将两个或多个字段合并为一个字段。</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>FORMAT(X, D)- 格式化数字X到D有效数字。</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>CURRDATE(), CURRTIME()- 返回当前日期或时间。</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>NOW() - 将当前日期和时间作为一个值返回。</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>MONTH(),DAY(),YEAR(),WEEK(),WEEKDAY() - 从日期值中提取给定数据。</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>HOUR(),MINUTE(),SECOND() - 从时间值中提取给定数据。</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>DATEDIFF(A,B) - 确定两个日期之间的差异,通常用于计算年龄</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>SUBTIMES(A,B) - 确定两次之间的差异。</p><p> <strong style="white-space: normal;"><span style="font-size: 16px;">·</span></strong>FROMDAYS(INT) - 将整数天数转换为日期值。</p><p> <strong>50、解释访问控制列表</strong></p><p> ACL(访问控制列表)是与对象关联的权限列表。这个列表是MySQL服务器安全模型的基础,它有助于排除用户无法连接的问题。</p><p> MySQL将ACL(也称为授权表)缓存在内存中。当用户尝试认证或运行命令时,MySQL会按照预定的顺序检查ACL的认证信息和权限。</p>
讯享网

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/201002.html