Mysql 导出数据表结构

$sql  =   " show create table category " ;
$res 
=  mysql_query($sql) or die(mysql_error());
while ($obj = mysql_fetch_object($res))
{
    print_r($obj);
    echo 
"<hr>";
}

输出
stdClass Object
(
    [Table] 
=>  category
    [Create Table] 
=>  CREATE TABLE `category` (
  `CategoryID` 
int ( 10 ) unsigned NOT NULL  default   ' 0 ' ,
  `CategoryName` varchar(
80 ) NOT NULL  default   '' ,
  `ParentID` 
int ( 10 ) unsigned NOT NULL  default   ' 0 ' ,
  `Keywords` varchar(
255 ) NOT NULL  default   '' ,
  `ProductCount` mediumint(
6 ) unsigned NOT NULL  default   ' 0 ' ,
  `TradeLeadCount` mediumint(
6 ) NOT NULL  default   ' 0 ' ,
  `CompanyCount` mediumint(
6 ) NOT NULL  default   ' 0 ' ,
  `B2soutletcount` mediumint(
6 ) unsigned NOT NULL  default   ' 0 ' ,
  `CategoryType` tinyint(
1 ) NOT NULL  default   ' 0 ' ,
  `Section` tinyint(
1 ) unsigned NOT NULL  default   ' 0 ' ,
  `IsLeaf` tinyint(
1 ) NOT NULL  default   ' 1 ' ,
  `Link` 
int ( 10 ) unsigned NOT NULL  default   ' 0 ' ,
  PRIMARY KEY  (`CategoryID`),
  KEY `GroupName` (`CategoryName`),
  KEY `ParentID` (`ParentID`),
  KEY `CategoryType` (`CategoryType`),
  KEY `Section` (`Section`)
) ENGINE
= MyISAM DEFAULT CHARSET = latin1
)

 

 

 

mysql > tee outmsg.log  -- 注把以后在命令行执行的结构都输入到outmsg.log文件中

mysql
>   ?  show
Name: 
' SHOW '
Description:
SHOW has many forms that provide information about databases, tables,
columns, or status information about the server. This section describes
those following:

SHOW [FULL] COLUMNS FROM tbl_name [FROM db_name] [LIKE 
' pattern ' ]
SHOW CREATE DATABASE db_name
SHOW CREATE FUNCTION funcname
SHOW CREATE PROCEDURE procname
SHOW CREATE TABLE tbl_name
SHOW DATABASES [LIKE 
' pattern ' ]
SHOW ENGINE engine_name 
{LOGS | STATUS }
SHOW [STORAGE] ENGINES
SHOW ERRORS [LIMIT [offset,] row_count]
SHOW FUNCTION STATUS [LIKE 
' pattern ' ]
SHOW GRANTS FOR user
SHOW INDEX FROM tbl_name [FROM db_name]
SHOW INNODB STATUS
SHOW PROCEDURE STATUS [LIKE 
' pattern ' ]
SHOW [BDB] LOGS
SHOW PLUGIN
SHOW PRIVILEGES
SHOW [FULL] PROCESSLIST
SHOW [GLOBAL 
|  SESSION] STATUS [LIKE  ' pattern ' ]
SHOW TABLE STATUS [FROM db_name] [LIKE 
' pattern ' ]
SHOW [OPEN] TABLES [FROM db_name] [LIKE 
' pattern ' ]
SHOW TRIGGERS
SHOW [GLOBAL 
|  SESSION] VARIABLES [LIKE  ' pattern ' ]
SHOW WARNINGS [LIMIT [offset,] row_count]

The SHOW statement also has forms that provide information about
replication master and slave servers and are described 
in
[replication
- sql]:

SHOW BINLOG EVENTS
SHOW MASTER LOGS
SHOW MASTER STATUS
SHOW SLAVE HOSTS
SHOW SLAVE STATUS

If the syntax 
for  a given SHOW statement includes a LIKE  ' pattern '
part, 
' pattern '   is  a  string  that can contain the SQL ` % '  and `_ '
wildcard characters. The pattern 
is  useful  for  restricting statement
output to matching values.

Several SHOW statements also accept a WHERE clause that provides more
flexibility 
in  specifying which rows to display. See [extended - show].
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值