Refactoring is a process of improving your source code without creating a new functionality. Refactoring helps you keep your code solid and easy to maintain.
Rename database objects
Place the caret at the object that you want to rename.
Navigate to Rename dialog.Shift+F6. If you edit an argument in the function, you can start typing a new name inline, or press Shift+F6 twice to invoke the
If you rename the element inline, you can click icons near the element, and select whether you want to rename it in comments and strings or all the text occurrences.
In the Rename dialog, type a new name for the object.
Review changes and click Refactor. To search for usages of the object name, click Preview.
Rename code in place
In the editor start renaming a column, a variable, or any other code element. DataGrip will display in the gutter.
Click the gutter icon or press Alt+Enter and apply a suggestion. DataGrip renames the code element and updates its usages accordingly.
Extract a variable
Place the caret at a variable in the function.
Select a part of the expression that you want to extract and press Enter.
Extract as a Common Table Expression (CTE)
CTE is a temporary result set that you can use within another SELECT, INSERT, UPDATE, or DELETE statements. In DataGrip you can extract a subquery and convert it to CTE.
Place the caret inside the subquery that you want to convert.
Preview refactoring changes
For some refactorings, DataGrip lets you preview changes before applying them.
To see potential changes (the list of usages where the refactoring will be performed), click Preview in the Refactoring Preview dialog.
Check the changes that are going to be made in the Find tool window. You can exclude Delete or remove Ctrl+X changes that you consider unnecessary.
Click Do Refactor to proceed with the changes.