Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the equivalent of all_tables and all_tab_columns in postgresql

Tags:

postgresql

I am trying to run oracle query

SELECT OWNER,  
       TABLE_NAME 
FROM ALL_TABLES;

SELECT COLUMN_NAME, 
       DATA_TYPE, 
       DATA_LENGTH, 
       NULLABLE, 
       COLUMN_ID, 
       DATA_PRECISION, 
       DATA_SCALE 
FROM ALL_TAB_COLUMNS 

in postgresql but it is not able to excute that because PostgreSQL doesn't have ALL_TAB_COLUMNS and ALL_TABLES

Can any body suggest what is the equivalent query of that

like image 544
Amrin Avatar asked Feb 15 '12 09:02

Amrin


People also ask

What is ALL_TAB_COLUMNS?

ALL_TAB_COLUMNS describes the columns of the tables, views, and clusters accessible to the current user. To gather statistics for this view, use the ANALYZE SQL statement or the DBMS_STATS package. Related Views. DBA_TAB_COLUMNS describes the columns of all tables, views, and clusters in the database.

What is Information_schema in PostgreSQL?

The information schema is a built-in schema that's common to every PostgreSQL database. You can run SQL queries against tables in the information_schema to fetch schema metadata for a database. For example, the following query fetches the names of all user-defined tables in a database: SELECT. table_name.


2 Answers

ALL_TABLES is equivalent to the (ANSI standard) view information_schema.tables: http://www.postgresql.org/docs/current/static/infoschema-tables.html

ALL_TAB_COLUMNS is equivalent to the (ANSI standard) view information_schema.columns: http://www.postgresql.org/docs/current/static/infoschema-columns.html

like image 56
a_horse_with_no_name Avatar answered Oct 16 '22 07:10

a_horse_with_no_name


information_schema.columns lacks the Num_Distinct and Num_Nulls information columns.

like image 33
Michael Avatar answered Oct 16 '22 06:10

Michael