How do I list all the column names in Netezza? - sql

Is there a query I can write to search all the column names for a particular database in Netezza?

Within the same database you can use the following query:
select *
from _v_odbc_columns1
where column_name like '%columnname%'
or a less Netezza specific query
select *
from information_schema.columns
where column_name like '%columnname%'

The important catalog views in netezza system are listed below
_V_USER: the user view gives information about the users in the netezza system.
_V_TABLE: the table view contains the list of tables created in the netezza performance system.
_V_RELATION_COLUMN: the relation column system catalog view contains the columns available in a table.
_V_TABLE_INDEX: this system catalog contains the information about the
indexes created on table. netezza does not support creating indexes on a table as of now.
_V_OBJECTS: lists the different objects like tables, view, functions etc. available in the netezza.
Example:
SELECT *
FROM _V_RELATION_COLUMN
WHERE
ATTNAME like '%GEO%' --SPECIFY COLUMN NAME
AND type = 'TABLE'

You would access something similar to an information_schema.
Column Name, %COW%', would use % as a wildcard...gathering any column that has 'COW' in the name
SELECT *
FROM _V_SYS_COLUMNS
WHERE
COLUMN_NAME like '%COW%'
AND TABLE_SCHEMA = 'DEV'
ORDER BY TABLE_NAME
;

Related

how to find column names which has particular value in snowflake for a particular schema. The schema may have more than 300 tables

Basically search for all the columns which has a specific value in multiples tables in a schema
In Snowflake, there is a 'COLUMNS' view which has this information. You can use the following commands:
use <Database_Name>;
select
column_name
from
information_schema.columns
where
table_schema='<schema_name>'
and column_name like '%value%'

Is there a way to get all column names in a table for IBM Netezza? [duplicate]

Is there a query I can write to search all the column names for a particular database in Netezza?
Within the same database you can use the following query:
select *
from _v_odbc_columns1
where column_name like '%columnname%'
or a less Netezza specific query
select *
from information_schema.columns
where column_name like '%columnname%'
The important catalog views in netezza system are listed below
_V_USER: the user view gives information about the users in the netezza system.
_V_TABLE: the table view contains the list of tables created in the netezza performance system.
_V_RELATION_COLUMN: the relation column system catalog view contains the columns available in a table.
_V_TABLE_INDEX: this system catalog contains the information about the
indexes created on table. netezza does not support creating indexes on a table as of now.
_V_OBJECTS: lists the different objects like tables, view, functions etc. available in the netezza.
Example:
SELECT *
FROM _V_RELATION_COLUMN
WHERE
ATTNAME like '%GEO%' --SPECIFY COLUMN NAME
AND type = 'TABLE'
You would access something similar to an information_schema.
Column Name, %COW%', would use % as a wildcard...gathering any column that has 'COW' in the name
SELECT *
FROM _V_SYS_COLUMNS
WHERE
COLUMN_NAME like '%COW%'
AND TABLE_SCHEMA = 'DEV'
ORDER BY TABLE_NAME
;

Find column in separate table

I've got table A with column X. Column X SHOULD exist within table B too, however, the name of table B is unknown to me.
Is there a way of finding table B?
I am using an Oracle database and SQL Developer. I cannot see anything of help in the contraints/dependencies sections of table A. I suspect the relationship between column X and table B is taken care of by the application interacting with the database.
Try with the following:
select *
from dba_tab_columns
where column_name = 'COLUMN_X'
and table_name != 'TABLE_A'
You could even study all procedures, package, triggers, etc using your column, to understand the way they manipulate the data in your column; to find these objects, try:
select NAME, TYPE, OWNER
from dba_source
where upper(text) like '%COLUMN_X%'
DBA_TAB_COLUMNS Table describes columns of all tables,view and clusters in the database. Refer Oracle Documentation. Both DBA_TAB_COLUMNS and ALL_TAB_COLUMNS provide similar information while ALL_TAB_COLUMNS provide info as accessible to the current user
Refer Oracle Documentation -
https://docs.oracle.com/cd/B19306_01/server.102/b14237/statviews_4146.htm#REFRN23277
https://docs.oracle.com/cd/B19306_01/server.102/b14237/statviews_2094.htm#I1020277

In Oracle, how do you search a tables' column-names?

I have a large table with over 50 columns. And I would like to search those columns for a particular word. How do I do this in Oracle ?
thanks
You can use the following:
select COLUMN_NAME from ALL_TAB_COLUMNS
where TABLE_NAME='your_table_name' and COLUMN_NAME like '%whatever_word_required%';
Explanation: ALL_TAB_COLUMNS describes the columns of the tables, views, and clusters accessible to the current user. So from all the tables, since you want to search in a particular table so give your table-name in the query and specify the criteria for columns using the LIKE.
Say if your table name is "Table1" and column-name you are trying to search is "Employee", so the query becomes:
select COLUMN_NAME from ALL_TAB_COLUMNS
where TABLE_NAME='Table1' and COLUMN_NAME like '%Employee%';
For reference see the Oracle Docs

What is Mysql select statement to show a list of tables?

I want to write a program that can show the user a list of tables in the database and also show the descriptions of those tables. So can I do a "select * from system_table" or something like that?
This will give you a list of tables:
show tables;
To describe each table:
describe table_name;
To get both at the same time try:
SELECT * FROM DOMAIN.TABLES WHERE TYPE = 'TABLE'
SELECT * FROM DOMAIN.COLUMNS WHERE TABLETYPE = 'TABLE'
The results are similar to MySql show and describe statements
In addition to show tables, MySQL 5.0+ also supports the INFORMATION_SCHEMA meta-database:
SELECT table_name, table_comment FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema = 'db_name';
information_schema.tables also has other information in it, if you're curious.
Note that if you didn't provide a comment when you created the table and use InnoDB, it will fill the table_comment column with unnecessary data, such as the InnoDB space reserved for this table or the foreign key constraints.