mysql基础面试题linux_15个 MySQL 基础面试题,DBA 们准备好了吗?

问题11:如何从表(比如 oc_users )中获取一个 field 对象(比如 uid)的所有数据?

答案:运行命令 select uid from oc_users;

MySQL> select uid from oc_users;

+-----+

| uid |

+-----+

| avi |

+-----+

1 row in set (0.03 sec)

问题12:假设你有一个名为 ‘xyz’ 的表,它存在多个字段,如 ‘createtime’ 和 ‘engine’。名为 engine 的字段由 ‘Memoty’ 和 ‘MyIsam’ 两种数值组成。如何只列出 ‘createtime’ 和 ‘engine’ 这两列并且 engine 的值为 ‘MyIsam’?

答案:运行命令 select create_time, engine from xyz where engine = ”MyIsam”;

mysql> select create_time, engine from xyz where engine="MyIsam";

+---------------------+--------+

| create_time        | engine |

+---------------------+--------+

| 2013-12-15 13:43:27 | MyISAM |

| 2013-12-15 13:43:27 | MyISAM |

| 2013-12-15 13:43:27 | MyISAM |

| 2013-12-15 13:43:27 | MyISAM |

| 2013-12-15 13:43:27 | MyISAM |

| 2013-12-15 13:43:27 | MyISAM |

| 2013-12-15 13:43:27 | MyISAM |

| 2013-12-15 13:43:27 | MyISAM |

| 2013-10-23 14:56:38 | MyISAM |

| 2013-10-23 14:56:38 | MyISAM |

| 2013-10-23 14:56:38 | MyISAM |

| 2013-10-23 14:56:38 | MyISAM |

| 2013-10-23 14:56:38 | MyISAM |

| 2013-10-23 14:56:38 | MyISAM |

| 2013-10-23 14:56:38 | MyISAM |

+---------------------+--------+

132 rows in set (0.29 sec)

问题13:如何列出表 ‘xrt’ 内 name 域值为 ‘linuxidc’,web_address 域值为 ‘linuxidc.com’ 的所有数据?

答案:运行命令 select * from xrt where name = “linuxidc” and web_address = “linuxidc.com”;

mysql> select  * from xrt where name = "linuxidc" and web_address = “linuxidc.com”;

+---------------+---------------------+---------------+

| Id                  | name                  | web_address |

+---------------+---------------------+----------------+

| 13                |  linuxidc              | linuxidc.com  |

+---------------+---------------------+----------------+

| 41                |  linuxidc              | linuxidc.com  |

+---------------+---------------------+----------------+

问题14:如何列出表 ‘xrt’ 内 name 域值不为 ‘linuxidc’,web_address 域值为 ‘linuxidc.com’ 的所有数据?

答案:运行命令 select * from xrt where name != "linuxidc" and web_address = "linuxidc.com";

mysql> select * from xrt where name != ”linuxidc” and web_address = ”linuxidc.com”;

+---------------+---------------------+---------------+

| Id            | name                | web_address  |

+---------------+---------------------+----------------+

| 1173          |  linuxidc            | linuxidc.com  |

+---------------+---------------------+----------------+

问题15:如何知道表内行数?

答案:运行命令 select count(*) from table_name;

mysql> select count(*) from Tables;

+----------+

| count(*) |

+----------+

|      282 |

+----------+

1 row in set (0.01 sec)

以上是文章的全部内容。这篇‘Linux 面试题’对您有任何帮助吗?别忘了在下面留言,写出您的宝贵意见。0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值