在MySQL中显示表格的所有字段?
要显示所有字段,请使用以下语法将数据库设置为table_schema,将特定表设置为table_name-
select column_name as anyAliasName from information_schema.columns where table_schema=database() and table_name=’yourTableName’\G
让我们首先创建一个表-
create table DemoTable1938 ( StudentId int, StudentName varchar(20), StudentAge int, StudentCountryName varchar(20), StudentMobileNumber bigint );
这是显示表的所有字段的查询-
select column_name as ALL_FIELDS from information_schema.columns where table_schema=database() and table_name='DemoTable1938'\G
这将产生以下输出-
*************************** 1. row *************************** ALL_FIELDS: StudentId *************************** 2. row *************************** ALL_FIELDS: StudentName *************************** 3. row *************************** ALL_FIELDS: StudentAge *************************** 4. row *************************** ALL_FIELDS: StudentCountryName *************************** 5. row *************************** ALL_FIELDS: StudentMobileNumber 5 rows in set (0.00 sec)
热门推荐
2 聚餐会祝福语简短
9 祝福语简短古诗词
10 给宝贝开学祝福语简短
11 浪漫的生日祝福语简短
12 师姐毕业送花祝福语简短
13 姐姐女儿结婚祝福语简短
14 男朋友新年祝福语简短
15 生日祝福语大全女生简短
16 新年稳重的祝福语简短
17 上嫂子生日祝福语简短
18 老师送的祝福语简短