"SCRIPT TO..." option in Datagrip? - postgresql

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.

Related

SSMS - Terminology for Select & Edit

Terminology question. In SSMS, when you list the various tables and right click on one, you get the 'Select Top 1000 Rows' & 'Edit Top 200 Rows', and depending on which on you click, it will take you to an interface that looks similar to the other, but clearly works differently. Does Microsoft have a specific name for these two interfaces? I had wanted to look up some settings for these and realized I don't even know what they're called. I've always called them Select Mode and Edit Mode, but searching that hasn't yielded anything useful.
The "Select top 1000 Rows" takes you to a query editor with a prewritten query in the below fore and automatically runs it:
/****** Script for SelectTopNRows command from SSMS ******/
SELECT TOP (1000) <Column Name>
[,<Column Name> ...
,<Column Name>]
FROM <Database Name>.<Schema Name>.<Object Name>
The window at the bottom is the results pane.
The "Edit Top 200 Rows" launches a query designer, based on the a similar query to the above (but the database name is omitted and the schema might be). Forget you ever saw this, and never use it again. The "feature" is actually full of bugs, it lacks functionality and support for a lot of features (especially newer ones, like temporal tables), and has some interesting "quirks". If you need to "edit" your data then write the appropriate INSERT, UPDATE and DELETE statements to alter your data.

SQL Developer 19.1 doesn't show the matching list of table names in worksheet editor

SQL Developer 19.1 - worksheet editor doesn't show matching list of table names from the schema. Eg. If I were to write a SQL query such as:
select * from TMP_EMPLOYEE_MASTER;
I am expecting SQL Developer to show me the table name after I have typed first few letters of the table name (eg. TMP_EM). But looks like SQL developer doesn't seem to be helping at all in highlighting the matching table names.
I know that this feature exists in SQL Developer. Just wondering why it isn't working
Edit 1:
I tried below options but still not working:
CTL+spacebar.
Change the entries in the preferences as mentioned in the screenshot. But this didn't help. The auto complete/suggestion for table name is not coming at all.
I'm guessing you have more than 10 tables that start with TMP
Increase the filter for Auto-Complete to something higher than 10 - or type more letters, or use Ctrl+Spacebar to 'force' the completion feature to fire.
That option is located in Tools - Preferences; search for "complet" and you'll see Code Editor: Completion Insight. Check both "SQL Worksheet" and "PL/SQL Editor" checkboxes, adjust popup speed if necessary.
Works for me ...

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.

How to auto-complete all columns in "select * from table" in SQL Server Management Studio

Write this:
Select * From tablea
Want this:
Select c1, c2, c3 ... From tablea
SQL Server Management Studio provides intellisense to pick one column at a time. It takes a while for table with lots of columns.
I can use Script Table as =>Select To=> New Query Edit Window, and the copy/paste to my original script. however is there a less interruptive way?
I write SQL a lots, thanks for help!
Found this myself.
Type Select * From TableA in SSMS.
Exactly Select text Select * From TableA.
Use Ctrl+Shift+Q to pop up Query Designer window.
Click OK. "*" is replaced by "c1, c2, c3..."
Query Designer auto-populates all the columns. just open it & close. if you want only portion of columns, I found it is still easier to delete them on text editor than trying to use mouse to uncheck them on GUI.
Still hope to find a way to eliminate the Keyboard/mouse switch on step 4? seems there is no short-cut key for the OK button.
Update 2019-06-24
Above method does not work for table in SQL Azure. ApexSQL SQL formatter seems working well for me, it's free.
Update 2020-10-30
found a similar function in LINQPad, it allows me to auto-complete all properties in LINQ, See here
In SQL Server Management Studio if you expand the object explorer and then the node for the particular table in question then you can drag the columns node into the query window and this will type out all of the column names for you.
There are probably better ways to do this, but that's what I use.
Totally understand this answer is not specific to SSMS but in VSCode via the mssql extension:
Write this:
Select *
From TableX
Place cursor after the * and press Ctrl+Spacebar and option to insert all columns appears
If your object explorer is open then use drag & drop feature.
e.g. Northwind
Step 1: Expand the database by single click on plus icon or just double click on "Northwind"
Step 2: Expand tables "Tables"
Now you will see "Columns", "Keys", "Constraints" etc
Click on "Columns" to drag to your editor window.
You can try for other as well like "Keys", "Constraints".
But for "Indexes", did not work for me.
Hope you will find useful tips.

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

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