简体   繁体   中英

Pervasive SQL query

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.

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

--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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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