I have a list of columns. I want to build a query to find if the columns exists in the ServicingDB database.
We can also use the filter for the tables starting with abcd (example).
Thanks in advance.
You can use the below query to find out the Specific column along with database name, table name etc.
select * from information_schema.columns where column_name = 'yourColumnName'
Related
Request
I want to list all the table names in a schema in association with the list of that table attributes. I'm using DBeaver, but I can download other software if it works. I don't mind about the output data extension: txt, excel, csv etc., but I'm not searching for an ER diagram.
Example
If the database schema contains these three tables
TABLE_A
ATTRIBUTE_A_1
ATTRIBUTE_A_2
ATTRIBUTE_A_3
TABLE_B
ATTRIBUTE_B_1
TABLE_C
ATTRIBUTE_C_1
ATTRIBUTE_C_2
I want to extract something like this:
TABLE_A
ATTRIBUTE_A_1
ATTRIBUTE_A_2
ATTRIBUTE_A_3
TABLE_B
ATTRIBUTE_B_1
TABLE_C
ATTRIBUTE_C_1
ATTRIBUTE_C_2
Thanks in advance!
I've find out that, in Oracle, it's possible to list all the columns visible by the user who executes this query:
SELECT
TABLE_NAME,
COLUMN_NAME
FROM
ALL_TAB_COLUMNS
ORDER BY
TABLE_NAME ASC
DBeaver doesn't support "info" and "describe" commands as SQLDeveloper does. You can use a query like "SELECT ... FROM user_tab_columns".
I have the following query which works perfectly when searching for tables that contain a specific field name that I am looking for in an Oracle database
however it does not work in Netezza (Data Mart) when using the Toad Data point tool. Can someone let me know if there is anything similar to the query below which would work in a Netezza Data Mart environment.
Select DISTINCT TABLE_NAME, COLUMN_NAME
FROM ALL_TAB_COLUMNS
WHERE COLUMN NAME LIKE '%EXANOKE_FIELD_NAME%'
Select DISTINCT TABLE_NAME, COLUMN_NAME
FROM COLUMNS
WHERE COLUMN_NAME LIKE '%EXANOKE_FIELD_NAME%';
I have just started using and learning SQL server
i am using a database wcm_staging (so tables in this database are like this - wcm_staging.dbo.cust_id, and there are many tables like this), I need to check the column names (variable names) in all the tables in this particular database.
Can some one help please about how to do it?
Many thanks,
Best
Ritika
This will list out all the table names and column names with data tyes
USE DATABASE NAME
GO
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME='TABLE NAME'
SELECT
OBJECT_NAME(object_id) AS [Table Name],
name AS [Column Name]
FROM sys.columns
ORDER BY 1
I have a huge database in Sql-Server and I need to get all the names of the tables into one new table that I have made. This can be done?
I appreciate your help.
The new table has the fields ID, TableName, Status. Id is the identity and status for now will be 1, not null
Use this query below to get all tables name from your database
SELECT name FROM sys.tables
Then you can do a insert query like -
insert into newtable(name) select * from sys.tables
I have a sql server database which contains 7000 tables and every table ends with a date. I need to find out all the tables of a particular date.
I have the table names as follows:
HouseKeeping_Stage1_12_6_14,
HouseKeeping_Stage1_13_6_14,
HouseKeeping_Stage1_14_6_14,
HouseKeeping_Stage2_12_6_14,
HouseKeeping_Stage2_13_6_14
I want to find out all the records which are associated with the date 12_6_14.
Please let me know how to write the query.
Using SSMS Object Explorer, right-click on the Tables node and select Filter-->Filter Settings. The list will be filtered accordingly.
Alternatively, you can query the catalog or INFORMATION_SCHEMA views:
SELECT
OBJECT_SCHEMA_NAME(object_id) AS schema_name
, name
FROM sys.tables
WHERE name LIKE '%[_]13[_]6[_]14%';
SELECT
TABLE_SCHEMA
, TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME LIKE '%[_]13[_]6[_]14%';
This should do the trick:
SELECT * FROM information_schema.tables
where table_name like '%12_6_14%'
Here is an example: http://sqlfiddle.com/#!6/304bd/1/0