List all tables with a specific column Name - sql

i didn't find the right answear here. So I work with a lot of different tables. The Schema of the Tables are GDBADMP.[Table_Name] or USCH1060.[Table_Name].
Now i search a way to list all tables with an exact column Name like PLZ_ID. The column contains different values, somtimes varchar or int
Like: Show all Tables (GDBADMP.[Table_Name]) with the column Name PLZ_ID
My first thoughts are like this:
SELECT *
FROM GDBADMP.*
WHERE PLZ_ID
Kind regards

Look at the syscat.columns catalog view. You may join it to syscat.tables by (tabschema, tabname) to get tables only (excluding views, for example).
Thanks to this comment. I found a solution!
SELECT *
FROM SYSCAT.COLUMNS a
WHERE a.colname = 'PLZ_ID'

I suggest using SYSIBM.SYSCOLUMNS which is a system table that contains all the fields in all tables.
Below a sample query that will return the tables in a form of creator.table:
SELECT TRIM(TBCREATOR)||'.'||TRIM(TBNAME) AS FULLTABLE
FROM SYSIBM.SYSCOLUMNS
WHERE NAME='PLZ_ID'

Related

Get column names stored in a different table

I have a table that has just a code for the individual column name like "A1G", "Z8H" etc.
This table is a really huge table. Therefore it would not help to manually add the alias name in the SELECT Statement like.
The description for each column code is stored in a different table:
Now I would like to SELECT * from the first table but with the right column header name.
This is stored in the second table within the filters Schema = 'ABC' and Table = 'A'.
That would be desired output:
How would you do that in SQL?
How can I change the column name?
You would be better off just creating a view with all the columns aliased to your preferred names. Once that's done you can select from the view and get the data back with the headings you want.
Look into Inner Join
Or Left Join.

Is there a query to retrieve all source table names and target table names of a particular mapping in informatica?

Is there any query that results from source table names and column table names using a mapping or mapping Id in informatica. This has been very hard and challenging
Like when we search up SELECT * FROM opb_mapping WHERE mapping_name LIKE '%CY0..%'
It is resulting in some details but I cannot find source table names and target table names. Help if you can.
Thanks.
You can use below view to get the data.
(Assuming you have full access to metadata tables.
select source_name, source_field_name,
target_name, target_column_name,
mapping_name, subject_name folder
from REP_FLD_MAPPING
where mapping_name like '%xx%';
Only issue i can see is, if you have overwrite sql, then you need to check sql for true source.

How can I select sqlite "check ... in [list]" options in SQLite?

Pretty much everything is in the title.
I'm looking for an SQLite equivalent of the following SQL command :
show columns from users where field = "category";
Given that the show statement doesn't exist in SQLite.
Thanks in advance
You can use meta data held in SQLite with query:
select
sm.name as table_name,
pti.name as column_name
from
sqlite_master sm
join
pragma_table_info(sm.name) as pti
where
pti.name like '%category%';
It returns (as can be seen) tables with column names. Then, you can filter output by column name, I used for example condition:
where pti.name like '%category%'
which returns only those column names including category.

Postgresql how do i find a table based on column name?

I know that I have a table with the column "fortyid" but I cant remember which table it is and I have like 350 tables in my database.
Is there a way to find all tables that has "fortyid" as column? (doesn't matter the type)
You can use the metadata defined by the SQL standard, specifically INFORMATION_SCHEMA.COLUMNS.
select c.*
from information_schema.columns c
where c.column_name = 'fortyid';

How to search a given text in a table in sql server

I want to search a text in a table without knowing its attributes.
Example : I have a table Customer,and i want to search a record which contains 'mohit' in any field without knowing its column name.
You are looking for Full Text Indexing
Example using the Contains
select ColumnName from TableName
Where Contains(Col1,'mohit') OR contains(col2,'mohit')
NOTE - You can convert the above Free text query into dynamic Query using the column names calculated from the sys.Columns Query
Also check below
FIX: Full-Text Search Queries with CONTAINS Clause Search Across Columns
Also you can check all Column Name From below query
Select Name From sys.Columns Where Object_Id =
(Select Object_Id from sys.Tables Where Name = 'TableName')
Double-WildCard LIKE statements will not speed up the query.
If you wanna make a full search on the table, you must surely be knowing the structure of the table. Considering the table has fields id, name, age, and address, then your SQL Query should be like:
SELECT * FROM `Customer`
WHERE `id` LIKE '%mohit%'
OR `name` LIKE '%mohit%'
OR `age` LIKE '%mohit%'
OR `address` LIKE '%mohit%';
Mohit, I'm glad you devised the solution by yourself.
Anyway, whenever you again face an unknown table or database, I think it will be very welcome the code snippet I just posted here.
Ah, one more thing: the answers given did not addressed your problem, did they?