Pervasive SQL query

2019-05-22 18:07发布

Does anyone have a query to search all columns in all tables in a Pervasive database for a specific value?

I am struggling to find any info on this.

Seems easy to do in sql server but not with Pervasive.

标签: sql pervasive
2条回答
ら.Afraid
2楼-- · 2019-05-22 18:39

--returns a list of all tables sorted by table name: Select * from X$File order by xf$name

--returns a list of all columns (in order) and their attributes for a table called "Person": select X$Field.* from X$Field, X$File where xe$File = xf$id and xf$name = 'Person' and xe$DataType < 200 order by xe$offset

You could use some sort of stored procedure to run through them all. This is a SQL server stored proc that you might be able to use as a guide.

http://vyaskn.tripod.com/search_all_columns_in_all_tables.htm

查看更多
\"骚年 ilove
3楼-- · 2019-05-22 18:50

You don't need a stored procedure. You can do it with this query:

select x$file.xf$name, X$Field.* from X$Field, X$File 
where xe$File = xf$id and 
xe$DataType < 200 
and xe$name = '<Column Name>'
order by xe$offset

Changing to the name of the column you are looking for.
For example, to find a column named "Name", you would use the statement:

select x$file.xf$name, X$Field.* from X$Field, X$File 
where xe$File = xf$id and 
xe$DataType < 200 
and xe$name = 'Name'
order by xe$offset

and the results are:

Xf$Name                 Xe$Id   Xe$File   Xe$Name                Xe$DataType   Xe$Offset   Xe$Size   Xe$Dec   Xe$Flags
====================   ======   =======   ====================   ===========   =========   =======   ======   ========
Course                     86        13   Name                             0           0         7        0          1
Dept                       92        14   Name                             0           0        20        0          1
Class                      68        12   Name                             0           4         7        0          1
查看更多
登录 后发表回答