如何在SQL数据库中读取表名 [英] How to read the Table name on my SQL Database

查看:278
本文介绍了如何在SQL数据库中读取表名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1。如何读取我的SQL数据库上的表名

2.如何读取表中的字段名称

解决方案

列出表在您的数据库中,尝试连接到数据库并使用:

  SELECT  TABLE_NAME 
FROM Information_Schema.Tables
WHERE Table_Type = ' BASE TABLE'



列出表格中的列:

  SELECT  * 
FROM Information_Schema.Columns
WHERE Table_Name = ' NameOfYourTable'


使用信息架构意见 [ ^ ]

示例:

1. http://stackoverflow.com/questions/3913620/get-all-table-names-of-a-particular-database-by-sql-query [ ^ ]

2. http ://stackoverflow.com/questions/1054984/how-can-i-get-column-names-from-a-table-in-sql-server [ ^ ]

1. How to read the Table name on my SQL Database
2. How to read the Field name on the table

解决方案

To list the tables in your DB, Try connecting to the DB and using:

SELECT TABLE_NAME
FROM Information_Schema.Tables
WHERE Table_Type = 'BASE TABLE'


To list the columns within a table:

SELECT * 
FROM Information_Schema.Columns 
WHERE Table_Name = 'NameOfYourTable'


Use Information Schema Views[^]
Some examples:
1. http://stackoverflow.com/questions/3913620/get-all-table-names-of-a-particular-database-by-sql-query[^]
2. http://stackoverflow.com/questions/1054984/how-can-i-get-column-names-from-a-table-in-sql-server[^]


这篇关于如何在SQL数据库中读取表名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆