简体   繁体   English

如何在数据库中的未知表中查找字段?

[英]How to find fields in a unknown table in a database?

Good morning!早上好!

I'm with the need to look in my database, one column of a table that does not know the name at first, what happens is the following:我需要查看我的数据库,一开始不知道名称的表的一列,发生的情况如下:

In my application created for each project, a table is created which takes the name of this project, taking the given name and concatenating with the date and time of creation.在我为每个项目创建的应用程序中,创建了一个表,该表采用该项目的名称,采用给定名称并与创建日期和时间连接。 So the name of this table is stored in another table called projects that have a field that tells the client that belongs to that project.因此,该表的名称存储在另一个名为 projects 的表中,该表有一个字段告诉客户属于该项目。 When I do SELECT want to see the names of application projects related to the ID's of customers, browse the database tables behind those those customers and bring me these tables, so that we can finally see the desired fields.我做SELECT的时候想看客户ID相关的应用项目名称,浏览那些客户背后的数据库表,把这些表给我,这样我们就可以看到想要的字段了。

Do not know if I could be clear, if they need more details just talk!不知道我能不能说清楚,如果他们需要更多的细节,就说吧!

Thanks!谢谢!

If I understood you correctly, you need to find the exact names of the tables that were named like your project plus they have some additional characters in their names (that look like dates and times).如果我理解正确,您需要找到与您的项目类似的表的确切名称,并且它们的名称中还有一些额外的字符(看起来像日期和时间)。

Well, you can list all the tables that start with the name of your project, using a query like this:好吧,您可以使用如下查询列出所有以项目名称开头的表:

SELECT *
FROM sys.tables
WHERE name LIKE 'yourprojectname%'

sys.tables is a system view where all your tables are listed. sys.tables是一个系统视图,其中列出了所有表。

' yourprojectname %' is a mask used for filtering through the list of tables. ' yourprojectname %'是用于过滤表列表的掩码。 The % character is neccessary. %字符是必需的。 It means 'any character or characters, any number of them (or none of them)' .它的意思是“任何一个或多个字符,任意数量(或没有)” (Without % the output would show you only one table whose name is exactly like your project's name. If such a table exists, that is.) (如果没有% output 将只显示一个名称与您的项目名称完全相同的表。如果存在这样的表,那就是。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM