获取MYSQL数据库和表的有关信息

来源:互联网 发布:数据库修复大师破解版 编辑:程序博客网 时间:2024/05/22 00:53
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
 3.5 获取数据库和表的有关信息
    MYSQL提供了几条获取数据库和表中信息的语句。这些语句对于了解数据库的内容及了解自己表的结构很有帮助。还可以将它们作为使用ALTER TABLE 的一种辅助手段;能够知道当前列是如何定义的,计划出怎样对列进行更改会更为容易。SHOW 语句可用来获取数据库和表的几个方面的信息,它有如下用法:

    DESCRIBE tbl_name 和EXPLAIN tbl_name 语句与SHOW COLUMNS FROM tbl_name功能相同。
    MYSQLshow 命令提供了某些与SHOW 语句相同的信息,它允许从外壳程序中取得数据库和表的信息:

    MYSQLdump 实用程序允许以CREATE TABLE 语句的形式查看表的结构。(与S H O WCOLUMS 语句比较,作者认为MYSQLdump 命令的输出结果更容易阅读,而且这个输出还显示了表中的索引。)但如果使用MYSQLd um p,要保证用- no - data 选项调用它,以防被表中数据把头搞晕。

   对于MYSQLshow 和MYSQLd um p,两者都可以指定一些有用的选项(如-- host)来与不同主机上的服务器进行连接。
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击