手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

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

[日期:2014-01-06] 来源:Linux中国   作者:Linux [字体:大 中 小]

问题6:如何列出某个数据库内所有表?

答案:在当前数据库运行命令 show tables;

MySQL> show tables;
+----------------------------+
| Tables_in_cloud            |
+----------------------------+
| oc_appconfig              |
| oc_calendar_calendars      |
| oc_calendar_objects        |
| oc_calendar_repeat        |
| oc_calendar_share_calendar |
| oc_calendar_share_event    |
| oc_contacts_addressbooks  |
| oc_contacts_cards          |
| oc_fscache                |
| oc_gallery_sharing        |
+----------------------------+
10 rows in set (0.00 sec)

问题7:如何获取表内所有 Field 对象的名称和类型?

答案:运行命令 describe table_name;

mysql> describe oc_users;
+----------+--------------+------+-----+---------+-------+
| Field    | Type        | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+-------+
| uid      | varchar(64)  | NO  | PRI |        |      |
| password | varchar(255) | NO  |    |        |      |
+----------+--------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

问题8:如何删除表?

答案:运行命令 drop table table_name;

mysql> drop table lookup;

Query OK, 0 rows affected (0.00 sec)

问题9:如何删除数据库?

答案:运行命令 drop database database-name;

mysql> drop database a1;

Query OK, 11 rows affected (0.07 sec)

问题10:如何查看表内所有数据?

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

mysql> select * from engines;
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| ENGINE    | SUPPORT | COMMENT                                                        | TRANSACTIONS | XA  | SAVEPOINTS |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| InnoDB    | YES    | Supports transactions, row-level locking, and foreign keys    | YES          | YES  | YES        |
| MRG_MYISAM | YES    | Collection of identical MyISAM tables                          | NO          | NO  | NO        |
| BLACKHOLE  | YES    | /dev/null storage engine (anything you write to it disappears) | NO          | NO  | NO        |
| CSV        | YES    | CSV storage engine                                            | NO          | NO  | NO        |
| MEMORY    | YES    | Hash based, stored in memory, useful for temporary tables      | NO          | NO  | NO        |
| FEDERATED  | NO      | Federated MySQL storage engine                                | NULL        | NULL | NULL      |
| ARCHIVE    | YES    | Archive storage engine                                        | NO          | NO  | NO        |
| MyISAM    | DEFAULT | Default engine as of MySQL 3.23 with great performance        | NO          | NO  | NO        |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
8 rows in set (0.00 sec)

linux
相关资讯       MySQL面试题 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款