How to auto-generate the columns needed for insert command
Answered
Hi experts,
Say that I have a simple insert command:
INSERT INTO schema.table1
SELECT (a bunch of columns)
FROM schema.table2
The problem is that I need to pick say 30 columns out of 50 columns of table2. How do I ask Datagrip to auto-generate these column names? I can even see the column names as a greyed hint but Datagrip refuses to "materialize" them.
Thanks!
Please sign in to leave a comment.
Hi Markus, when I press Ctrl-space when the cursor is just after the " * " then I can expand to all columns.
More or less the same is true for the insert into statement. If I type " ( " after the tablename all the target columns gets inserted.
Does that help?
Hi Leon, thanks for the help, but I'm seeking to generate just the names of the columns in table1, not of table2. This gives me the full list of table2 but I only need the ones in table1.
Hi Markus, that is exactly what I explain in "More or less the same is true for the insert into statement. If I type " ( " after the tablename all the target columns gets inserted.". So in your "lingo": INSERT INTO schema.table1( <<== the parenthesis is important/the trigger for DG to generate the fields. Then you get the hint:
Thanks Leon, it's not exactly what I want, but works to some extend. I only need to copy the line and paste it after SELECT. Thanks!