Questions tagged [information-schema]
The information schema is a set of views providing metadata for objects in relational databases: tables, views, columns, stored procedures, accounts etc.
503
questions
-1
votes
1
answer
45
views
PostgreSQL: SQL script to get a list of all foreign key references to a table
I have a table, breeds with a primary key of breed_name and would like to get a list of all tables, columns and constraints that reference breeds regardless of column referenced in breeds. If there is ...
0
votes
1
answer
24
views
PL/pgSQL dynamic query in stored function to return any table's column names
I am trying to write a stored function with a dynamic query that returns all column names from a table that can then be used to create a dynamic query for a joined view trigger function. But ...
1
vote
1
answer
174
views
Azure Databricks INFORMATION_Schema
I am using Azure Databricks and need to have a way to find out which columns are allowed to be NULL in several tables. For MySQL there is the well-known Information_Schema which does not exist in ...
0
votes
0
answers
559
views
Spring BOOT JPA, Custom SQL Query with mysql added row number in Select from INFORMATION SCHEMA
Hi i have working query in mySQL:
QUERY:
SELECT TABLE_NAME,(@row_number:=@row_number + 1) AS num FROM (SELECT @row_number:=0) AS t,INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA LIKE 'dmind';
Database ...
1
vote
0
answers
52
views
I need to include the table_schema, table_name and column_name in my query output with values
I am creating a report to identify the maximum batch_id for each table and table schema across our databases.
I want it to look something like this:
table_schema
table_name
column_name
...
-1
votes
3
answers
208
views
Dynamic SQL to get rows from information_schema
Let’s say I’m looking for a specific column in my database so I have something like this
SELECT COLUMN_NAME, TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME like ‘%employeeid%’
But I ...
1
vote
1
answer
188
views
Get column data from multiple tables dynamically
I have a list of tables for which I need to search if a single data point (userid) exists in any one table.
The following query gives list of tables with column userid:
select table_name
from ...
1
vote
1
answer
93
views
How to find information on all columns in a SQLite database?
Searching online, it's pretty easy to find the way to get information on all columns in a SQLite table: use the pragma table_info(name) with the name of the table. But every SQL database I've seen ...
0
votes
1
answer
230
views
Why can't I join to information_schema.columns to get column list for my tables? - Redshift SQL
I have a table called relevant_tables that resembles:
schema_name table_name
AAA AA
AAA AB
AAA AC
BBB BA
I came across the information_schema....
0
votes
0
answers
25
views
In MYSQL, Is it possible to use the LEAST function with column_names?
I am wondering if it is possible to integrate, in MYSQL, the functions LEAST / GREATEST together with SELECT column_name FROM information_schema.table name. If possible, it would save me a lot of time....
1
vote
0
answers
17
views
Do we have procedure details in snowflake.account_usage schema
I could see there is a separate FUNCTION view and PROCEDURE view in the information schema of databases. While in Snowflake.account_usage schema, the FUNCTION view have both Functions and Procedure ...
2
votes
0
answers
84
views
Search all identifiers in a postgres database
In my postgres logs, I'm getting a notification every few seconds saying "sql_error_code = 42622". Apparently, this means an identifier is too long. The identifier is unfamiliar to me, so I'...
1
vote
1
answer
325
views
Why INFORMATION_SCHEMA.VIEWS does not list up materialized view in Snowflake?
I could not able to see materialized view while executing below query in Snowflake even though current role in session is owner role which has all the privileges on an object (here materialized view)
...
0
votes
2
answers
197
views
Get column timestamp when they got added in Bigquery
I'm trying to find which all new columns got added to the table. Is there any way to find it? I was thinking to get all columns for a table with timestamps when they got created or modified so that I ...
0
votes
2
answers
34
views
Search a group of SQL Server views for tables use
I am trying to search through a group of views to see if they contain certain tables.
For example: let's say I have about 30 views and I want to see if they use this particular table. How can I go ...
1
vote
1
answer
50
views
how can we identify big query queries ran using Tableau in big query information schema
Is there a way to identify queries ran where using Tableau in table INFORMATION_SCHEMA.JOBS_BY_PROJECT in GCP Big Query
0
votes
0
answers
42
views
How to get TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_DEFAULT along with CONSTRAINT_NAME: INFORMATION_SCHEMA in mySQL?
I just need to get the columns which has Primary Key, Foreign Key along with TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_DEFAULT
0
votes
0
answers
9
views
Is there a way to see when someone downloads data locally in the INFORMATION_SCHEMA table within BigQuery?
The job_type = 'EXTRACT' shows when someone downloads data to google drive, but not when someone downloads a file and stores it locally. Is there anyway to see this?
0
votes
1
answer
44
views
PostgreSQL dynamic query: find most recent timestamp of several unrelated tables
I have a number of tables, and many of them have a timestamp column. I can get a list of every table with a timestamp column:
SELECT table_name
FROM information_schema.columns
WHERE table_schema='...
0
votes
0
answers
58
views
MySQL understanding INFORMATION_SCHEMA.PROFILING
How to understand BLOCK_OPS_IN because the documentation doesn't provide good understanding information
:
BLOCK_OPS_IN: indicate the number of block input and output operations
+----------+-----+----...
1
vote
1
answer
78
views
Insufficient privilege while creating custom view or table inside INFORMATION_SCHEMA in Snowflake
I am getting insufficient privilege error while trying to create custom views and tables under INFORMATION_SCHEMA even though I tried to create it with ACCOUNTADMIN role which has all the privileges ...
0
votes
1
answer
73
views
PostgreSQL information schema query for tables without a specific data type
I'm trying to write a PostgreSQL query to get all the tables (from a specified schema) which don't have any columns of a specific data type, for example, show all tables without any integer type ...
0
votes
0
answers
35
views
How can i store in a MySQL Database, a Table that holds for each table in my database its daily size, extracted from information_schema?
I've created a Table called analytics_daily_table_sizes with four columns: date, table_schema, table_name, size_mb.
This table holds for each Table in my Database, its size in MB, updated on a daily ...
1
vote
0
answers
90
views
How can root@% grant a user to select all entries in information_schema.Tables
MySQL 5.7.24
After creating a user, it can
select count(*) from information_schema.Tables
and get 50, let's say.
And root@% can get 300 with the same SQL.
how can root@% grant the created user to ...
0
votes
1
answer
50
views
How do I compare two columns from different tables in different databases?
Say I have Table_1 in Database_1 with 25 Columns
and say I have Table_2 in Database_2 with 19 Columns
I want to compare the columns in Table_1 and Table_2 and output Columns that exist in Table_1 but ...
0
votes
1
answer
76
views
MS-SQL - Count all rows per table in a DB per Select Command [duplicate]
I wrote this select command, which gives me tables with the associated number of columns from the database.
SELECT
t.TABLE_NAME,
(SELECT
COUNT(*)
FROM
INFORMATION_SCHEMA....
1
vote
0
answers
68
views
How to access apache solr server installed at google colab online?
I am using Google Colab for apache solr 8.5.0 server implementation of Content Based Image Retrieval (CBIR) system, The solr is showing its port (8983), along with this, i have tried couple of IP ...
1
vote
1
answer
277
views
INFORMATION_SCHEMA.COLUMNS sorted alphabetically initially, then a few days later sorted by ORDINAL_POSITION
After MySQL 8.0.25 (InnoDB engine on Windows) upgrade from MariaDB (10.1.26, and I don't think we were using InnoDB engine on Linux), every time our DB server restarts, we run into this issue:
SELECT *...
0
votes
2
answers
429
views
Deny access to information_schema in MariaDB
I am looking for the best way possible to deny users access to information_schema in Maria DB. By default each user has the right to access the information_schema, but can see only the rows in the ...
1
vote
1
answer
33
views
How to get a default column value from MySQL 5.7 information_schema.columns with appropriate quoting?
I maintain Beekeeper Studio, an open source SQL GUI.
I have a problem with information_schema.columns in MySQL 5.7.
when running:
select * from information_schema.columns where table_name = ?`
It ...
0
votes
1
answer
90
views
Detect Sql-view structure
I create a view like this
SELECT dbo.BaharInOut.BCode, dbo.Bahar.BName
FROM dbo.Bahar INNER JOIN
dbo.BaharInOut ON dbo.Bahar.BCode = dbo.BaharInOut.BCode
And ...
0
votes
1
answer
14
views
Query MariaDB for Installation folder?
I can see there is a lot of information in the information_schema database, is there a standard way to get the installation path from the database?
I can see there are GLOBAL_VARIABLES table has ...
0
votes
0
answers
55
views
Automatic_Clustering_History Information in Snowflake
Currently there are no clustered key defined tables in our account. Also no automatic clustering enabled for any tables. But I see some data when I query Information_Schema....
0
votes
1
answer
142
views
Why the warning about VIEW_COLUMN_USAGE.VIEW_SCHEMA?
I recently noticed that the documentation for the INFORMATION_SCHEMA.VIEW_COLUMN_USAGE view at Microsoft's Docs website contains a warning for both the VIEW_SCHEMA and TABLE_SCHEMA columns:
** ...
0
votes
1
answer
121
views
What is the meaning of last_modified_timestamp in BigQuery
I am running the below query, trying to understand the meaning of last_modified_timestamp. Is it when the data in the table was last updated (DML operation) or when the table structure was last ...
2
votes
2
answers
176
views
How do I SELECT all (table, column) referencing the same column as foreign key
(TL;DR at the end)
I am working on merging 2 well sized postgres databases.
As there are ID conflicts and many foreign keys I would have enjoyed that UPDATE foo SET bar_id = bar_id + 100000 CASCADE ...
2
votes
1
answer
143
views
Synthetic TABLE types show up in ALL_COLL_TYPES, but OBJECT types don't show in ALL_TYPES in Oracle 18c
When creating the following:
create view v (a, b) as select 1, 2 from dual;
create or replace package p as
type t is table of v%rowtype;
function f return t pipelined;
end p;
/
I can see some ...
0
votes
0
answers
31
views
Postgresql where statement across tables with different column aliases
This doesn't seem to be a common use case, but one that I run into frequently. I have multiple tables with similar structure but different column aliases. For example day vs date. This makes it ...
0
votes
1
answer
126
views
MySQL get list of tables ending with specific name and it's (table's) comment
I have multiple tables in my multiple databases.
On different servers, i use MySQL / PostgreSQL / MS SQL.
I keep short table namesbut the comments given to the tables are with full explanation.
I want ...
0
votes
1
answer
29
views
How do I solve the Missing Paranthesis error
I'm trying to a create table command to create a relation;
create table Driver(
Driver_Licence char(15) primary key,
SSN int unique,
First_Name varchar(50) not null,
Last_Name varchar(50),
...
0
votes
0
answers
146
views
How to make this SQL using REFERENCED_TABLE_NAME work in H2
I was in a situation where the only way to drop a foreign key constraint was this solution;
-- YOU MUST SPECIFY THESE VARIABLES TO FULLY IDENTIFY A CONSTRAINT
SET @table_name = '...';
SET @column_name ...
-1
votes
1
answer
209
views
Dynamic row hash based on information_schema for MySQL
We process a large amount of data on a daily basis & one way we reduce processing time is by skipping any records that have not changed from the previous day. We do this by calculating an MD5 hash ...
0
votes
1
answer
696
views
How to find the number of rows for all views in a schema?
Sometimes I have access to schemas with hundreds of views (when using the Snowflake Data Marketplace). How can I find the number of rows for each of these views?
What I need is an efficient way to do ...
0
votes
2
answers
150
views
Use INFORMATION_SCHEMA get list of all datatypes in a MySQL database?
I know there are lists of the datatypes that MySQL supports all over the internet, but is there a way I can use INFORMATION_SCHEMA to programmatically list them in real-time in my application?
I'm ...
0
votes
0
answers
221
views
MySQL information_schema.tables UPDATE_TIME refresh on specific column change with ANALYZE TABLE
Is it possible to update the INFORMATION_SCHEMA.TABLES UPDATE_TIME for a specific table when a specific column is changed in this table?
I know that MySQL saves its cache to the TABLES on a timeout ...
1
vote
0
answers
61
views
MYSQL 8.0.23-cloud left join on information_schema.KEY_COLUMN_USAGE is not working
I imported sakila-schema.sql to MYSQL 8.0.23-cloud. I am trying to get constraint name of the column which is part a foreign key.
requiredConstraintName column in second output row is coming wrong. It ...
0
votes
1
answer
424
views
INFORMATION_SCHEMA.COLUMNS suddenly empty
Yesterday I developed an SQL query using the COLUMN_NAMES field from INFORMATION_SCHEMA.COLUMNS on an SQL Server database.
The query worked perfectly fine, especially the query of COLUMN_NAMES ...
0
votes
1
answer
145
views
SQL INFORMATION_SCHEMA.VIEWS
I want to make 2020 that include 2019 for all view contents, but I have a problem with the long views.Is View Definition column has a character limit? Because as far as I can see, there is a problem ...
0
votes
1
answer
706
views
How to join System tables or Information Schema tables with User defined tables in Redshift
I have a requirement where I need to join Redshift Information schema table with User defined table. I have tried below queries and getting mentioned errors.
select *
from pg_table_def a join ...
0
votes
1
answer
57
views
Filter columns before calculating SUM (Error: Error converting data type varchar to int)
I need to calculate Min/Max/etc. values for columns in my a table. So I want to filter the columns from INFORMATION_SCHEMA to get only the numeric ones.
The following query returns an error: Error ...