I'd like to get the View definitions from a PostgreSQL schema so that I can create the same views on a target database. I get all the information from the SchemaCrawler except the table that the View is based on. Is this possible? Or instead of the View definition, can SchemaCrawler include the base table name?
I tried setting the -parents switch to see if Views would include the "parent" table, but I get no such information.
[EDIT]
Here's what I'm getting:
{
"foreignKeys": [],
"indexes": [],
"columns": [
{
"size": 50,
"nullable": true,
"databaseSpecificType": "varchar",
"generated": false,
"dataType": "VARCHAR",
"name": "view_description",
"width": "",
"decimalDigits": 0,
"remarks": "",
"autoIncremented": false
},
{
"size": 10,
"nullable": true,
"databaseSpecificType": "numeric",
"generated": false,
"dataType": "NUMERIC",
"name": "revenue",
"width": "(10, 0)",
"decimalDigits": 0,
"remarks": "",
"autoIncremented": false
},
{
"size": 10,
"nullable": true,
"databaseSpecificType": "numeric",
"generated": false,
"dataType": "NUMERIC",
"name": "assets",
"width": "(10, 0)",
"decimalDigits": 0,
"remarks": "",
"autoIncremented": false
},
],
"name": "my_view",
"definition": "",
"type": "view",
"triggers": [],
"tableConstraints": [],
"remarks": "",
"primaryKey": {}
}
and here's what I'm expecting:
{
"foreignKeys": [],
"indexes": [],
"columns": [
{
"size": 50,
"nullable": true,
"databaseSpecificType": "varchar",
"generated": false,
"dataType": "VARCHAR",
"name": "view_description",
"width": "",
"decimalDigits": 0,
"remarks": "",
"autoIncremented": false
},
{
"size": 10,
"nullable": true,
"databaseSpecificType": "numeric",
"generated": false,
"dataType": "NUMERIC",
"name": "revenue",
"width": "(10, 0)",
"decimalDigits": 0,
"remarks": "",
"autoIncremented": false
},
{
"size": 10,
"nullable": true,
"databaseSpecificType": "numeric",
"generated": false,
"dataType": "NUMERIC",
"name": "assets",
"width": "(10, 0)",
"decimalDigits": 0,
"remarks": "",
"autoIncremented": false
},
],
"name": "my_view",
"definition": "CREATE VIEW my_view ...",
"type": "view",
"triggers": [],
"tableConstraints": [],
"remarks": "",
"primaryKey": {}
}
or have an entry like "parentTable": "my_table" which I can use to construct the CREATE VIEW script via a template or code.
Thanks!