Simpler process to alter views
- Dominant language
- Java
- Stars
- 51.8k
- Forks
- 4.4k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 188
Description
**Is your feature request related to a problem? Please describe.**
I often need to alter the definition statements of views in various types of databases. Because it's such a frequent task, I would like that process to be more ergonomic in DBeaver. Currently I perform these steps:
1. Get the current definition statement:
a) right-click on the view object; click _Generate SQL_ > _DDL_ > _Copy_; or
b) open the view object; go to _Properties_ > _Definition_; press `F5` to refresh the cached definition statement; select the statement; copy it
2. Open a new SQL script and paste in the statement
3. Remove the surrounding text that DBeaver has added to the statement [1]:
- ~The `-- [view_name] source\n\n` comment at the beginning~
Update: the added comment can now be disabled in the application preferences, by disabling the "Connections" > "Metadata" > "Generate DDLs with extra info" option.
- The semicolon at the end
You must remember this each time (Update: only for the semicolon; the prepended comment can now be turned off in the preferences as described above). Otherwise, when you alter and execute the statement in the following steps, the comment and the semicolon become part of the view DDL. In my case those additions show up as changes in the Git repository that tracks the view definitions. The comment line can even get added to the DDL repeatedly, each time that one forgets to remove it before altering the view.
5. ~Change the `CREATE` keyword to `ALTER`.~
Update 2025-03-27: This step is not needed anymore, at least not in the database type that I use. DBeaver now generates the DDL as an `ALTER` statement instead of a `CREATE` statement by default.
7. Alter the definition statement as desired and execute it
[1] For example, a view that is defined as
```
CREATE VIEW some_view AS
SELECT some_column
FROM some_table
```
is shown in DBeaver as
```
-- some_view source
CREATE VIEW some_view AS
SELECT some_column
FROM some_table;
```
**Describe the solution you'd like**
Ideally I would like steps 1-4 to be a two-click process (right-click on view object > _Generate SQL_ > click _ALTER DDL_) or, even better, a single keyboard shortcut. This should open the ALTER VIEW statement, without any additions, in a new script.
**Describe alternatives you've considered**
I have written scripts that fetch the DDL of a given view from the database schema information and copy them to the clipboard, replacing steps 1, 3 and 4. However, as that requires supplying parameters to the script, it is not very efficient either. I would prefer a solution within DBeaver.
One thing that would already help is if DBeaver's additions to the DDL statement as described in step 3 could be disabled. Perhaps I have overlooked an option that already exists to configure this?
Contributor guide
Assessment
This issue has not been assessed yet.