DataGrip does not add replace keyword when extracting DDL
Answered
With Oracle 12c and DataGrip 2017.3, I see the following issue. When generating a DDL script for Views and Packages, it omits replace keyword. e.g. it prints:
"create view my_view" instead of "create or replace my_view."
This leads to an error when I try to re-create the view object. I have to add replace keyword manually.
Please sign in to leave a comment.
@vasily chernov
Thanks for help.
1. I know how to change keymap, question is that default keymap is too complex.
2. Using "Generate DDL to Console" is a workaround, isn't it? It is very contr-intuitive that basic commands to view function code do not support function editing (when "or replace" is omitted, it leads to such heavy consequences). Is your team working on the solution?
Hi Vasily,
I tried SQL Generator as well, the same result. No replace keyword is added.
I have the same problem.
Doesnt matter what i use it won't create or replace function.
Using Datagrip 2018.1 and Postgresql 10.2
SQL Generator works OK for now, but it is not an everyday solution. Editing of stored procedures is too complex: I need to 1. "jump to editor" (double-click or F4), 2. "SQL scripts - SQL generator" (Ctrl+Alt+G), 3. copy result to clipboard, 4. Ctrl+A in editor, 5. Ctrl+V.
I am writing DB procedures all the days, and 5 (!) steps for such simple action...
Note: "Generate DDL to clipboard" still returns "create ..." instead of "create or replace". "Generate DDL to console" opens console with right script, but you have to delete each console after use, plus default hotkey (Ctrl+Shift+Alt+B) for this is too complex and does not work on my linux with 2 keyboard layouts switched by Alt+Shift.
I just have installed the DataGrip, so I can misunderstand many things - sorry for it. But in this case you can think about accessibility of the DataGrip for new users (I used pgAdmin III previously).
P.S.: I still love JetBrains products, good work!
@Nea14e
First of all, you need to update to the latest DataGrip EAP since there were some issues with generator options.
To change default hotkey you need to go to Keymap settings and change it:
In case you invoke "Generate DDL to Console" it generates DDL with "create... if not exists" and "create or replaced" options enabled:
Will it be helpful for you?
Hi,
What action do you invoke to generate DDL?
It's recommended to use SQL Generator to specify proper create options:
Thank you.
@ Indrek Kalluste & @Nurlan Nurmanov
There is an issue in SQL Generator in DG 2018.1 EAP 2. I'll be fixed in the next EAP.
@Nea14e
Yes, we've got plans to improve flow with code generations. There is an issue https://youtrack.jetbrains.com/issue/DBE-6160 to track progress and vote for.
Is there a way to change the default behavior for double clicking the package body object in the Database pane to Generate DDL To Console or Generate DDL To Clipboard? Currently in 2019.3 it just opens the package body in an editor tab without the 'create or replace' functionality. Also, is there a way to make it include the schema name in the package body?
@Gsteiner,
Use SQL Generator for `create or replace` and schema qualification options.
Also, vote for https://youtrack.jetbrains.com/issue/DBE-6160