您好,欢迎访问一九零五行业门户网

Mysql导出数据表结构_MySQL

$sql = show create table category;
$res = mysql_query($sql) or die(mysql_error());
while($obj=mysql_fetch_object($res))
...{
print_r($obj);
echo
;
}
输出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].
其它类似信息

推荐信息