![]() This is a better version of the multi-line insert script for DataGrip, than what is currently floating around. The source code of the object is the core part of the DDL script which is needed to create this object.(My)SQL Batch Multi-Line Insert Data Export/Extracter for DataGrip In other words, the CREATE statement is not part of the object’s source code. The source code is stored inside the database. The most common objects found with the source code are views, functions, and stored procedures. In many other tools, to update the source code, you would need to generate the CREATE OR REPLACE script, make the required changes and run it. In DataGrip it works a little differently. You just need to make the changes you need to make and the proper script will be generated for you. People coming from other tools all make the same mistake: they open the DDL, copy it, modify it, adjust the CREATE statement (usually add the OR REPLACE part) and run the new script. This is not the way you are supposed to update the source code. Loading sourcesįor any data source, DataGrip performs the process called ‘introspection’ – the IDE retrieves all the metadata for objects in advance. This means that all source code is loaded when the introspection is performed. You might be asking: if the source code is loaded when introspection is performed, doesn’t it mean that they are out-dated? In Oracle there is the possibility not to load sources by choosing a lower introspection level: You can manage this process by choosing the required value in the Load Sources for options in the data source properties. Handling this situation will be covered later in our tutorial. The flowĭouble-clicking on the object in the database explorer or pressing Cmd/Ctrl+B on it in the SQL script opens the DDL editor. In case of the view, double-clicking on it in the database explorer opens the data: to open the DDL explorer click on the DDL button in the toolbar. Here you can find the CREATE script for the object. Important! The object references in the generated script are not qualified, in other words, %view_name% is used rather than the %schema_name%.%view_name%. The reason for this is the ability to copy the script for applying it in another context. If you want a script with qualified references, use the SQL generator. In the DDL editor, you can change the source code. When you edit the source code of any object, DataGrip tracks changes and highlights them in the gutter.įor example, add a comment line to a procedure or a function. If you click the highlighted line in the gutter, a small toolbar is displayed with the Show Diff button. ![]() You can click the Show Diff button to see the difference between the code that you added and the source code.Īfter you made the required changes, click the Submit button.ĭataGrip will generate the modification script and show you a preview. If you are okay with the result, click on OK and the script will be executed in the database. changing the object’s signature or object renaming.Īs a result, the required source code will be changed.ĭataGrip not only adds OR REPLACE to the creation script, but it can also handle more difficult situations, i.e. When it’s needed, DROP and CREATE scripts will be created. When the changes are made in the DDL editor, but not submitted yet, DataGrip stores them until you submit them. For example, if you changed several objects, several changed DDL are cached waiting for being applied. In the tool window called Database Changes, you can observe all pending source code changes and submit them all together at once. Outdated cached objectsĪs we mentioned, DataGrip caches the source code which was loaded at the introspection. Synchronize: fetch changes from the database and update the cached local object.If you see this warning in the IDE, you can choose one of the following actions to take: If an object that you opened was updated from a third-party location, you will see a notification that the cached object differs from the source code of the same object in the database. Disable check: disable this notification.Īlso, there might be a conflict between your version of the object source code and that in the database.For example, when you have modified the same source code as someone else and clicked Submit. You can forcefully replace the source code of the object in the database using Force Refactoring or you can synchronize the object state and then proceed with changes by clicking Abort Refactoring and Synchronize. If you’ve selected Abort Refactoring and Synchronize, DataGrip aborts the submit operation and fetches the changes from the database just like if you had clicked Synchronize. In this notification, you can choose between the following options: If the conflict still exists, you will see the following notification.
0 Comments
Leave a Reply. |