Click here to Skip to main content
15,567,257 members
Home / Discussions / Database
   

Database

 
GeneralRe: Get all tables under a database in Postgre Pin
_Flaviu13-Jan-22 22:24
_Flaviu13-Jan-22 22:24 
GeneralRe: Get all tables under a database in Postgre Pin
Victor Nijegorodov13-Jan-22 22:28
Victor Nijegorodov13-Jan-22 22:28 
GeneralRe: Get all tables under a database in Postgre Pin
_Flaviu14-Jan-22 1:01
_Flaviu14-Jan-22 1:01 
GeneralRe: Get all tables under a database in Postgre Pin
CHill6014-Jan-22 2:16
mveCHill6014-Jan-22 2:16 
GeneralRe: Get all tables under a database in Postgre Pin
_Flaviu14-Jan-22 2:47
_Flaviu14-Jan-22 2:47 
GeneralRe: Get all tables under a database in Postgre Pin
Victor Nijegorodov14-Jan-22 3:05
Victor Nijegorodov14-Jan-22 3:05 
GeneralRe: Get all tables under a database in Postgre Pin
TomasNemecr30-Aug-22 2:15
professionalTomasNemecr30-Aug-22 2:15 
GeneralRe: Get all tables under a database in Postgre Pin
TomasNemecr30-Aug-22 2:20
professionalTomasNemecr30-Aug-22 2:20 
Get create table statements for a database under a schema.

<pre lang="SQL">
SELECT TABLE_NAME, 'CREATE TABLE '||TABLE_NAME|| ' ('||STRING_AGG(CONCAT( C1, C2, C3, C4, C5, C6 ),', ')||')' AS QUERY FROM ( SELECT C.TABLE_NAME, '"'||C.COLUMN_NAME||'"' || ' ' || CASE WHEN DATA_TYPE='ARRAY' THEN LTRIM(UDT_NAME,'_')||'[]' ELSE DATA_TYPE END AS C1, CASE WHEN CHARACTER_MAXIMUM_LENGTH > 0 THEN '(' || CHARACTER_MAXIMUM_LENGTH || ')' END AS C2, CASE WHEN NUMERIC_PRECISION > 0 AND NUMERIC_SCALE < 1 THEN NULL END AS C3, CASE WHEN NUMERIC_PRECISION > 0 AND NUMERIC_SCALE > 0 THEN NULL END AS C4, CASE WHEN IS_NULLABLE = 'NO' THEN ' NOT NULL' END AS C5, CASE WHEN COLUMN_DEFAULT IS NOT NULL AND COLUMN_DEFAULT NOT LIKE 'nextval%' THEN ' DEFAULT' END || ' ' || REPLACE(COLUMN_DEFAULT, '::CHARACTER VARYING', '') AS C6 FROM INFORMATION_SCHEMA.COLUMNS C, INFORMATION_SCHEMA.TABLES T WHERE C.TABLE_CATALOG='tpch' AND T.TABLE_CATALOG='tpch' AND T.TABLE_SCHEMA='public' AND C.TABLE_NAME=T.TABLE_NAME AND C.TABLE_SCHEMA='public' AND T.TABLE_TYPE IN ('BASE TABLE') ORDER BY C.TABLE_NAME, C.ORDINAL_POSITION ) AS STRING_COLUMNS GROUP BY TABLE_NAME
AnswerRe: Get all tables under a database in Postgre Pin
Richard MacCutchan14-Jan-22 0:39
mveRichard MacCutchan14-Jan-22 0:39 
GeneralRe: Get all tables under a database in Postgre Pin
_Flaviu14-Jan-22 1:06
_Flaviu14-Jan-22 1:06 
GeneralRe: Get all tables under a database in Postgre Pin
Richard MacCutchan14-Jan-22 1:13
mveRichard MacCutchan14-Jan-22 1:13 
GeneralRe: Get all tables under a database in Postgre Pin
_Flaviu14-Jan-22 4:32
_Flaviu14-Jan-22 4:32 
QuestionList all tables from a specific database Pin
_Flaviu12-Jan-22 1:41
_Flaviu12-Jan-22 1:41 
AnswerRe: List all tables from a specific database Pin
Peter_in_278012-Jan-22 2:18
professionalPeter_in_278012-Jan-22 2:18 
GeneralRe: List all tables from a specific database Pin
_Flaviu12-Jan-22 2:35
_Flaviu12-Jan-22 2:35 
AnswerRe: List all tables from a specific database Pin
k505412-Jan-22 2:35
mvek505412-Jan-22 2:35 
GeneralRe: List all tables from a specific database Pin
_Flaviu12-Jan-22 2:59
_Flaviu12-Jan-22 2:59 
GeneralRe: List all tables from a specific database Pin
k505412-Jan-22 5:13
mvek505412-Jan-22 5:13 
GeneralRe: List all tables from a specific database Pin
_Flaviu12-Jan-22 5:32
_Flaviu12-Jan-22 5:32 
GeneralRe: List all tables from a specific database Pin
Richard MacCutchan12-Jan-22 5:39
mveRichard MacCutchan12-Jan-22 5:39 
GeneralRe: List all tables from a specific database Pin
_Flaviu12-Jan-22 6:19
_Flaviu12-Jan-22 6:19 
GeneralRe: List all tables from a specific database Pin
Richard MacCutchan12-Jan-22 6:41
mveRichard MacCutchan12-Jan-22 6:41 
GeneralRe: List all tables from a specific database Pin
_Flaviu12-Jan-22 7:16
_Flaviu12-Jan-22 7:16 
GeneralRe: List all tables from a specific database Pin
Richard MacCutchan12-Jan-22 7:43
mveRichard MacCutchan12-Jan-22 7:43 
AnswerRe: List all tables from a specific database Pin
Sakshi Jain 202213-Jul-22 0:18
Sakshi Jain 202213-Jul-22 0:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.