1、MYSQL根据字段名查询所属表
MYSQL里面需要根据某个字段名,查询该字段名所在的表。这种情况主要是出现在比如你忘了表名,只知道有这样一个字段名,想找出那张表。第二种情况可能是,同一个字段名属于外键,你想找出例如 ID 这个字段到底有多少个表拥有。
可以通过information_schema库当中的columns表来完成 如下代码来实现:
use information_schema;
select * from columns where column_name='字段名' ;
2、获取某个表中字段
sqlserver执行sql脚本
SQLServer --------- 将sql脚本文件导入数据库
Navicat连接sqlserver错误
Navicat for SQL Server创建连接提示错误08001怎么办
MySQL中information_schema是什么
[ERROR] Fatal error: Please read “Security” section of the manual to find out how to run mysqld as r
https://blog.csdn.net/qq_36350532/article/details/79591803
windows server 2012 R2 安装mysql(一)
windows server 2012 R2 安装mysql(一)
Windows MongoDB的安装及配置图文说明(非常详细)
Windows MongoDB的安装及配置图文说明(非常详细)
MongoDB详解,用心看这篇就够了【重点】(含linux环境下安装)
零基础学会MongoDB启动与停止
链接数据库错误(is not allowed to connect tothis mmysql server)
is not allowed to connect tothis mmysql server
Authentication plugin ‘caching_sha2_password‘ cannot be loaded问题
Authentication plugin ‘caching_sha2_password‘ cannot be loaded问题
mysql sslmode_你的MySQL服务器开启SSL了吗?
mysql sslmode_你的MySQL服务器开启SSL了吗?
mysql查询表的列名,顺序不对?
information_schema.columns表中有一个ordinal_position字段,表示的是列标识号,其实就是字段编号,你可以看看这些字段标号是不是按照你现在有字段顺序摆列的,如果是,那么用ordinal_position排序就可以了。
如果不是,而是按照你查询information_schema.columns表的顺序编的号,那么可能在建表后有过插入字段(比原来表中没有第四题字段一类的),或者修改字段名称(这个也可能修改字段编号),那么就将数据备份重建该表,这样应该就没有问题了,不过可能也需要按照ordinal_position排序。
来源百度问答,
借鉴上述思想采用一下语句
select COLUMN_NAME from information_schema.COLUMNS where TABLE_SCHEMA = 'acctruecloud_ncp' and TABLE_NAME = 'pdtmgr_category' ORDER BY ordinal_position