bitscn.com
mysql查表语句
[sql]
describe table_name;
这个命令用来显示一个表格的结构
+----------+-----------+------+-----+---------+-------+
| field | type | null | key | default | extra |
+----------+-----------+------+-----+---------+-------+
| id | int(11) | no | pri | null | |
| username | char(20) | no | | null | |
| password | char(20) | no | | null | |
| niname | char(20) | no | | null | |
| sex | char(10) | no | | null | |
| phone | char(20) | yes | | null | |
| address | char(100) | yes | | null | |
+----------+-----------+------+-----+---------+-------+
和这个命令可以实现同样效果的是:
show columns from table_name;
show create table table_name;//显示某个表格被创建时所用的sql语句
create table user | create table `user` (
`id` int(11) not null,
`username` char(20) not null,
`password` char(20) not null,
`niname` char(20) not null,
`sex` char(10) not null,
`phone` char(20) default null,
`address` char(100) default null,
primary key (`id`)
) engine=innodb default charset=latin1
bitscn.com