Generating all 'data dictionary' reports under each 'object' in postgres - postgresql

I have a database with about 50 something tables. I would like to run the report "Data Dictionary" on each table.
Ideally, I would like them all to be in one report, for example, in PGAdminIII, if I right click select "Tables" I will get a report of all the 'objects' and under each one a data dictionary report.
Is there an automatic way of doing this, or an plugin that I can install to postgres? Or is there something analogous to this?

If I understand correctly, you're referring to the ability to right mouse click on a table in PgAdminIII and select Reports > Data Dictionary report?
I'm not aware of any way to do that from PgAdminIII. You could look into using a different tool such as SchemaSpy. Another option (as alluded to by #kgrittn) is to use psql \d with the \H flag to generate html output. My solution (since SchemaSpy didn't do what I needed, and I needed the same output for both Postgres and Oracle) was to roll my own using perl, DBD::Pg and Template::Toolkit.
Update: Added GitHub link.

I wrote a fairly simple Postgres data dictionary generator in Python that spans all schemas and tables within a specified database. If it doesn't have exactly what you want it would be fairly easy to modify.
https://github.com/kylejmcintyre/pypostgreports

Related

"SCRIPT TO..." option in Datagrip?

Decided to pick up Datagrip for my Postgres database.
I've worked with SSMS/MS SQL-Server a lot, and one of the nice things about SSMS is the option to select a table and then a menu option called "SCRIPT TO..." and it'll give another list of auto-generated select, update, delete, etc queries.
Does Datagrip have a similar function? I'm struggling to find it.
In DataGrip there is another concept of creating queries, editor-centered:
Live Templates. When you are in the editor you can quickly create any type of query. For example, for SELECT * FROM <table_name> just type sel and press Tab. Then choose the table. The same for INSERT (type ins). All live templates can be found in Preferences | Editor | Live Templates
Generate functionality: Alt+Ins or Cmd+N. It is not customizable but good to create objects.
Anyway, your point is fair and there is a feature request in DataGrips' tracker: https://youtrack.jetbrains.com/issue/DBE-2762. Please upvote and comment there.

Access/Get SQL Developer Table 'Details'

I have a list of tables in an Oracle Schema. I use SQL Developer to build my queries. I can click on each table within the schema in SQL Developer and get access to a number of tabs, one of which is 'Details':
Within the 'Details' window, I have a property called 'Comments' which contains a description of what the table is for.
Now, I have quite a few tables and I want to somehow grab the table name and description in that comments property for each table and put it into a spreadsheet. Is there any way to do that in SQL Developer? Maybe a query? Or some built in function that iterates over each table and provides that information? I thought about using python, but I'm not sure I can access the 'Details' of the table.
Every once in a while, I find a solution before i have some of you awesome people answer for me, so i thought I'd post up what I found. This is the query I found that works:
select * from all_tab_comments where owner = 'your_schema_name_here'
This provides a list of all the tables in the schema (owner) I want and provides the comments I was looking for. From there, I can just export to an excel spreadsheet.

DB2 AS400 Triggers

I've been tasked with finding a way to migrate data into a DB2 AS400 database. When the data is entered (currently manually) on the front end, the system is doing some calculations and inserting the results in a table.
My understanding is that it's using a trigger to do so. I don't know very much about this stuff, but I have written code to directly insert values into that same table. Is there a way for me to figure out what trigger is being fired when users enter data manually?
I've looked in QSYS2/SYSTRIGGERS and besides not making much sense to me, I see no triggers that belong to the SCHEMA with my table in it.
Any help here would be awesome, as I am stuck.
SELECT *
FROM QSYS2.SYSTRIGGERS
WHERE TABSCHEMA = 'MYSCHEMA'
AND TABNAME = 'MYTABLE'
Should work fine.
If you'd prefer to use a 5250 command line, the Display File Description (DSPFD) command will show you the triggers on a file (table)
DSPFD FILE(MYSCHMA/MYTABLE) TYPE(*TRG)
Lastly, trigger information is available via the IBM i Navigator GUI. Either the older fat client version or the newer web based one.

Using Select query, nothing merges onto Crystal report

I have a Crystal template that I am modifying in developer because we are changing the datasource from an Access file to our Oracle DB. I created a database field that accurately connects to Oracle and added a select statement that because pulls a field from a particular table
select s.field from table s;
On the right hand side, under database fields, I see my command and can right click and browse the data, which right now returns two values.
I also made a formula field using an Azalea barcode function that calls the values (I think, this is where stuff is going wrong, I guess)
The formula field is
BarcodeC39ASCII({Command.field})
So this should take the data and format it into the barcode, except when I use print preview or print out the report, no data is merged.
I've tested this by creating a new formula field with just the Command.field, and still no data is merged. I imagine there is something really obvious that I am missing and would appreciate any input.
So unless I misunderstood your question, you are changing your datasource from Access DB to Oracle DB, correct? Assuming that the database structure remains the same then all you should need to do is go into Database -> Set Datasource Location and set the datasource location from the Access DB to the Oracle DB and your existing report should work as it did. You might have to map some fields, but that should be the extend of it. Is that what you are trying to do?
Chris

Search in all tables in PgAdmin

In PgAdmin, is it possible to search for a value in ALL tables? In phpmyadmin this is possible and quite convenient. You search for an ID value and find all the tables in which it occurs. I can't seem to find this function in PgAdmin.
Does it exist?
It currently doesn't exist in PgAdmin.
There's custom function for this. You can use it from Query tool. See [How to search a specific value in all tables (PostgreSQL)?
](as of today, there are two modifications in answers there that include column name, progress reporting)