mySQL查询表字所有字段的方法:使用“SHOW FROM”语句配合FulL关键字来查询,语法“SHOW FulL ColUMNS FROM table_name”,可以显示指定数据表的所有字段信息。
mySQL查询表字所有字段
1、查看所有表名:
show tables [from db_name];
2、查看字段信息
SHOW FulL ColUMNS FROM table_name
获取以下信息
FIEld :字段名
Type:字段类型
Collation:字符集(MysqL 5.0以上有)
Null :是否可以为NulL
Key:索引(PRI,unique,index)
Default:缺省值
Extra:额外(是否 auto_increment)
Privileges:权限
Comment:备注(MysqL 5.0以上有)
MysqL> create table teacher # 创建teacher表 -> ( -> ID int (5) auto_increment not null primary key, -> name char(10) not null, -> address varchar(50) default 'No.1 MID school', -> year date -> );query OK, 0 rows affected (0.02 sec)MysqL> show tables;+------------------+| tables_in_school |+------------------+| teacher |+------------------+1 row in set (0.00 sec)MysqL> show full columns from teacher; # 显示teacher表的所有字段+---------+-------------+-------------------+------+-----+-----------------+----------------+---------------------------------+---------+| FIEld | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |+---------+-------------+-------------------+------+-----+-----------------+----------------+---------------------------------+---------+| ID | int(5) | NulL | NO | PRI | NulL | auto_increment | select,insert,update,references | || name | char(10) | latin1_swedish_ci | NO | | NulL | | select,insert,update,references | || address | varchar(50) | latin1_swedish_ci | YES | | No.1 MID school | | select,insert,update,references | || year | date | NulL | YES | | NulL | | select,insert,update,references | |+---------+-------------+-------------------+------+-----+-----------------+----------------+---------------------------------+---------+4 rows in set (0.01 sec)MysqL> drop table teacher; # 删除teacher表query OK, 0 rows affected (0.03 sec)MysqL> show tables;Empty set (0.00 sec)MysqL>
推荐教程:mysql视频教程 总结
以上是内存溢出为你收集整理的mysql如何查询表字所有字段?全部内容,希望文章能够帮你解决mysql如何查询表字所有字段?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)